Class AdminClientBuilder
A builder for IAdminClient.
Inherited Members
Namespace: Confluent.Kafka
Assembly: Confluent.Kafka.dll
Syntax
public class AdminClientBuilder
Constructors
AdminClientBuilder(IEnumerable<KeyValuePair<string, string>>)
Initialize a new AdminClientBuilder instance.
Declaration
public AdminClientBuilder(IEnumerable<KeyValuePair<string, string>> config)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<string, string>> | config | A collection of librdkafka configuration parameters (refer to https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) and parameters specific to this client (refer to: ConfigPropertyNames). At a minimum, 'bootstrap.servers' must be specified. |
Properties
Config
The config dictionary.
Declaration
protected IEnumerable<KeyValuePair<string, string>> Config { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<KeyValuePair<string, string>> |
ErrorHandler
The configured error handler.
Declaration
protected Action<IAdminClient, Error> ErrorHandler { get; set; }
Property Value
Type | Description |
---|---|
Action<IAdminClient, Error> |
LogHandler
The configured log handler.
Declaration
protected Action<IAdminClient, LogMessage> LogHandler { get; set; }
Property Value
Type | Description |
---|---|
Action<IAdminClient, LogMessage> |
OAuthBearerTokenRefreshHandler
The configured OAuthBearer Token Refresh handler.
Declaration
public Action<IProducer<Null, Null>, string> OAuthBearerTokenRefreshHandler { get; set; }
Property Value
Type | Description |
---|---|
Action<IProducer<Null, Null>, string> |
StatisticsHandler
The configured statistics handler.
Declaration
protected Action<IAdminClient, string> StatisticsHandler { get; set; }
Property Value
Type | Description |
---|---|
Action<IAdminClient, string> |
Methods
Build()
Build the AdminClient instance.
Declaration
public virtual IAdminClient Build()
Returns
Type | Description |
---|---|
IAdminClient |
SetErrorHandler(Action<IAdminClient, Error>)
Set the handler to call on error events e.g. connection failures or all brokers down. Note that the client will try to automatically recover from errors that are not marked as fatal. Non-fatal errors should be interpreted as informational rather than catastrophic.
Declaration
public AdminClientBuilder SetErrorHandler(Action<IAdminClient, Error> errorHandler)
Parameters
Type | Name | Description |
---|---|---|
Action<IAdminClient, Error> | errorHandler |
Returns
Type | Description |
---|---|
AdminClientBuilder |
Remarks
Executes on the poll thread (a background thread managed by the admin client).
SetLogHandler(Action<IAdminClient, LogMessage>)
Set the handler to call when there is information available to be logged. If not specified, a default callback that writes to stderr will be used.
Declaration
public AdminClientBuilder SetLogHandler(Action<IAdminClient, LogMessage> logHandler)
Parameters
Type | Name | Description |
---|---|---|
Action<IAdminClient, LogMessage> | logHandler |
Returns
Type | Description |
---|---|
AdminClientBuilder |
Remarks
By default not many log messages are generated.
For more verbose logging, specify one or more debug contexts using the 'debug' configuration property.
Warning: Log handlers are called spontaneously from internal librdkafka threads and the application must not call any Confluent.Kafka APIs from within a log handler or perform any prolonged operations.
SetOAuthBearerTokenRefreshHandler(Action<IProducer<Null, Null>, string>)
Set SASL/OAUTHBEARER token refresh callback in provided conf object. The SASL/OAUTHBEARER token refresh callback is triggered via IAdminClient's admin methods (or any of its overloads) whenever OAUTHBEARER is the SASL mechanism and a token needs to be retrieved, typically based on the configuration defined in sasl.oauthbearer.config. The callback should invoke OAuthBearerSetToken(IClient, string, long, string, IDictionary<string, string>) or OAuthBearerSetTokenFailure(IClient, string) to indicate success or failure, respectively.
An unsecured JWT refresh handler is provided by librdkafka for development and testing purposes, it is enabled by setting the enable.sasl.oauthbearer.unsecure.jwt property to true and is mutually exclusive to using a refresh callback.
Declaration
public AdminClientBuilder SetOAuthBearerTokenRefreshHandler(Action<IProducer<Null, Null>, string> oAuthBearerTokenRefreshHandler)
Parameters
Type | Name | Description |
---|---|---|
Action<IProducer<Null, Null>, string> | oAuthBearerTokenRefreshHandler | the callback to set; callback function arguments: IProducer - instance of the admin client's inner producer instance which should be used to set token or token failure string - Value of configuration property sasl.oauthbearer.config |
Returns
Type | Description |
---|---|
AdminClientBuilder |
SetStatisticsHandler(Action<IAdminClient, string>)
Set the handler to call on statistics events. Statistics are provided as a JSON formatted string as defined here: https://github.com/edenhill/librdkafka/blob/master/STATISTICS.md
Declaration
public AdminClientBuilder SetStatisticsHandler(Action<IAdminClient, string> statisticsHandler)
Parameters
Type | Name | Description |
---|---|---|
Action<IAdminClient, string> | statisticsHandler |
Returns
Type | Description |
---|---|
AdminClientBuilder |
Remarks
You can enable statistics by setting the statistics interval using the statistics.interval.ms configuration parameter (disabled by default).
Executes on the poll thread (a background thread managed by the admin client).