1919#ifndef PULSAR_SERVICE_INFO_PROVIDER_H_
2020#define PULSAR_SERVICE_INFO_PROVIDER_H_
2121
22- #include < pulsar/ClientConfiguration.h>
2322#include < pulsar/ServiceInfo.h>
2423
24+ #include < functional>
25+
2526namespace pulsar {
2627
2728class PULSAR_PUBLIC ServiceInfoProvider {
@@ -35,18 +36,23 @@ class PULSAR_PUBLIC ServiceInfoProvider {
3536 /* *
3637 * Get the initial `ServiceInfo` connection for the client.
3738 * This method is called **only once** internally in `Client::create()` to get the initial `ServiceInfo`
38- * for the client to connect to the Pulsar service. Since it's only called once, it's legal to return a
39- * moved `ServiceInfo` object to avoid unnecessary copying.
39+ * for the client to connect to the Pulsar service, typically before {@link initialize} is invoked.
40+ * Since it's only called once, it's legal to return a moved `ServiceInfo` object to avoid unnecessary
41+ * copying.
4042 */
4143 virtual ServiceInfo initialServiceInfo () = 0;
4244
4345 /* *
4446 * Initialize the ServiceInfoProvider.
4547 *
46- * @param onServiceInfoUpdate the callback to update `client` with the new `ServiceInfo`
48+ * After the client has obtained the initial `ServiceInfo` via {@link initialServiceInfo}, this method is
49+ * called to allow the provider to start any background work (for example, service discovery or watching
50+ * configuration changes) and to report subsequent updates to the service information.
51+ *
52+ * @param onServiceInfoUpdate the callback to deliver updated `ServiceInfo` values to the client after
53+ * the initial connection has been established
4754 *
48- * Note: the implementation is responsible to invoke `onServiceInfoUpdate` at least once to provide the
49- * initial `ServiceInfo` for the client.
55+ * Implementations may choose not to invoke `onServiceInfoUpdate` if the `ServiceInfo` never changes.
5056 */
5157 virtual void initialize (std::function<void (ServiceInfo)> onServiceInfoUpdate) = 0;
5258};
0 commit comments