Apollo C++ Client
C++ client for Apollo Configuration Center
Loading...
Searching...
No Matches
apollo_client.h
Go to the documentation of this file.
1
6
7#pragma once
8#include "apollo_types.h"
9
10namespace apollo
11{
12namespace client
13{
14class ApolloClient;
15using ClientPtr = std::shared_ptr<ApolloClient>;
16using NotificationCallback =
17 std::function<void(const NamespaceType& n, const Configures& olds, const Configures& news, Changes&& changes)>;
18using NotificationCallbackPtr = std::weak_ptr<NotificationCallback>;
19
30{
31public:
35 virtual ~ApolloClient() = default;
36
49 virtual void startLongPolling(int long_polling_interval_ms = long_poller_interval_default) = 0;
50
58 virtual void stopLongPolling() = 0;
59
74 virtual Configures getConfigures(const NamespaceType& s_namespace) = 0;
75
91 virtual void setNotificationsListener(NotificationCallbackPtr notificationCallback) = 0;
92};
93
109ClientPtr makeApolloClient(const std::string& apollo_url,
110 const std::string& app_id,
111 Opts&& opts = Opts(),
112 LoggerPtr logger = nullptr);
113
114} // namespace client
115} // namespace apollo
ClientPtr makeApolloClient(const std::string &apollo_url, const std::string &app_id, Opts &&opts=Opts(), LoggerPtr logger=nullptr)
Creates a new Apollo client instance.
Apollo Client Library Type Definitions.
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
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
Interface for the Apollo configuration center client.
Definition apollo_client.h:30
virtual Configures getConfigures(const NamespaceType &s_namespace)=0
Retrieves configuration values from the ApolloClient cache.
virtual void setNotificationsListener(NotificationCallbackPtr notificationCallback)=0
Sets a callback for configuration change notifications.
virtual void stopLongPolling()=0
Stops the long polling thread.
virtual void startLongPolling(int long_polling_interval_ms=long_poller_interval_default)=0
Starts a long polling thread for configuration updates.
virtual ~ApolloClient()=default
Virtual destructor to ensure proper cleanup in derived classes.
Options for configuring the Apollo client.
Definition apollo_types.h:73