Apollo C++ Client
C++ client for Apollo Configuration Center
Loading...
Searching...
No Matches
apollo_types.h
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <map>
10#include <memory>
11#include <vector>
12#include <string>
13
14namespace apollo
15{
16namespace client
17{
18
19constexpr auto long_poller_interval_default = 1000;
20
22using NamespaceType = std::string;
23
34
39struct Change
40{
42 std::string key_;
43 std::string value_;
44
45 Change(ChangeType type, std::string&& key, std::string&& value)
46 : change_type_(type)
47 , key_(std::move(key))
48 , value_(std::move(value))
49 {
50 }
51
52 Change(ChangeType type, const std::string& key, const std::string& value)
53 : change_type_(type)
54 , key_(key)
55 , value_(value)
56 {
57 }
58 ~Change() = default;
59};
60
62using Changes = std::vector<Change>;
63
65using Configures = std::map<std::string, std::string>;
66
72struct Opts
73{
74 std::string cluster_name_ = "default";
75 std::string label_ = "";
76 std::vector<NamespaceType> namespaces_ = {"application"};
80};
81
82enum class LogLevel
83{
84 Disabled,
85 Error,
86 Warning,
87 Info,
88 Debug,
89};
90
92{
93public:
94 virtual ~ILogger() = default;
95
96 virtual LogLevel getLogLevel() const = 0;
97 virtual void setLogLevel(LogLevel level) = 0;
98 virtual void log(LogLevel level, const std::string& message) = 0;
99};
100using LoggerPtr = std::shared_ptr<ILogger>;
101
102} // namespace client
103} // namespace apollo
std::string NamespaceType
Type alias for namespace identifiers.
Definition apollo_types.h:22
std::vector< Change > Changes
List of configuration changes.
Definition apollo_types.h:62
ChangeType
Enum class representing the type of change in configuration.
Definition apollo_types.h:29
@ Deleted
Definition apollo_types.h:32
@ Added
Definition apollo_types.h:30
@ Updated
Definition apollo_types.h:31
constexpr auto long_poller_interval_default
Definition apollo_types.h:19
std::map< std::string, std::string > Configures
Map of key-value pairs representing a namespace's configuration.
Definition apollo_types.h:65
Definition apollo_types.h:92
Structure representing a change in configuration.
Definition apollo_types.h:40
ChangeType change_type_
Definition apollo_types.h:41
std::string value_
Definition apollo_types.h:43
std::string key_
Definition apollo_types.h:42
Options for configuring the Apollo client.
Definition apollo_types.h:73
std::vector< NamespaceType > namespaces_
Definition apollo_types.h:76
int connection_timeout_ms_
Definition apollo_types.h:77
std::string cluster_name_
Definition apollo_types.h:74
std::string label_
Definition apollo_types.h:75
int request_read_timeout_ms_
Definition apollo_types.h:78
int request_write_timeout_ms_
Definition apollo_types.h:79