mkdir build && cd build
# This flag generates a `compile_commands.json` file for integration with tools like clangd.
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
# Use `make -jN` to speed up the build process, where `N` is the number of parallel jobs.
make -j4
# Now build the docs target, which generates the documentation.
# This requires Doxygen version 1.14.0 to be installed on your system.
# If you don't have Doxygen installed, you can skip this step.
# ref: https://github.com/doxygen/doxygen
# docs output will be built in the build/docs directory
cmake --build . --target docs
auto notification_callback_ptr = std::make_shared<apollo::client::NotificationCallback>(
{
std::cout << "configuration changed for namespace: " << n << std::endl;
for (auto ns : changes)
{
switch (ns.change_type_)
{
std::cout << "namespace:" << n << " Added: " << ns.key_ << " = "
<< ns.value_ << std::endl;
break;
std::cout << "namespace:" << n << " Modified: " << ns.key_ << " = "
<< ns.value_ << std::endl;
break;
std::cout << "namespace:" << n << " Deleted: " << ns.key_ << std::endl;
break;
}
}
});
apollo::client::ClientPtr client;
std::string app_id = "test";
std::string apollo_url = "http://localhost:8080";
try
{
client->setNotificationsListener(notification_callback_ptr);
client->startLongPolling();
}
catch (const std::exception& e)
{
throw std::runtime_error("Error initializing Apollo client: " + std::string(e.what()));
}
auto configures = client->getConfigures("config1");
...
...
...
client->stopLongPolling();
Apollo Configuration Center Client Library.
ClientPtr makeApolloClient(const std::string &apollo_url, const std::string &app_id, Opts &&opts=Opts(), LoggerPtr logger=nullptr)
Creates a new Apollo client instance.
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
@ Deleted
Definition apollo_types.h:32
@ Added
Definition apollo_types.h:30
@ Updated
Definition apollo_types.h:31
std::map< std::string, std::string > Configures
Map of key-value pairs representing a namespace's configuration.
Definition apollo_types.h:65
Options for configuring the Apollo client.
Definition apollo_types.h:73
std::vector< NamespaceType > namespaces_
Definition apollo_types.h:76
std::string cluster_name_
Definition apollo_types.h:74