Class SchemaRegistrySerdeBuilder<TBuilder>
EXPERIMENTAL: subject to change or removal.
Common configuration for the builders of Schema Registry serializers and deserializers - how the Schema Registry client itself is obtained.
There are three ways to supply the client, exactly one of which must be used:
SetSchemaRegistryClient(ISchemaRegistryClient), to use a client the application constructed. Necessary when the application needs the client for something else too, such as registering encryption keys or creating associations before producing, and allows a single client to be shared across serdes and clients. The application retains ownership: the client is not disposed along with the serde.
SetSchemaRegistryConfig(SchemaRegistryConfig), to have the builder construct a CachedSchemaRegistryClient from configuration. The shortest form, and enough for most applications.
SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder), to have the builder construct a client that needs more than configuration alone - an authentication header value provider or a proxy, neither of which can be expressed in a string-to-string SchemaRegistryConfig.
In the latter two cases the resulting client is owned by the serde, which is in turn owned by the producer or consumer that built it, and is disposed along with it.
Inheritance
Inherited Members
Namespace: Confluent.SchemaRegistry
Assembly: Confluent.SchemaRegistry.dll
Syntax
public abstract class SchemaRegistrySerdeBuilder<TBuilder> where TBuilder : SchemaRegistrySerdeBuilder<TBuilder>
Type Parameters
| Name | Description |
|---|---|
| TBuilder | The concrete builder type, returned by the setters so that calls can be chained. |
Fields
ruleRegistry
The rule registry to construct the serde with, if any.
Declaration
protected RuleRegistry ruleRegistry
Field Value
| Type | Description |
|---|---|
| RuleRegistry |
schemaRegistryClient
The Schema Registry client supplied by the application, if any.
Declaration
protected ISchemaRegistryClient schemaRegistryClient
Field Value
| Type | Description |
|---|---|
| ISchemaRegistryClient |
schemaRegistryClientBuilder
The builder to construct a Schema Registry client with, if any.
Declaration
protected ISchemaRegistryClientBuilder schemaRegistryClientBuilder
Field Value
| Type | Description |
|---|---|
| ISchemaRegistryClientBuilder |
schemaRegistryConfig
The configuration to construct a Schema Registry client from, if any.
Declaration
protected SchemaRegistryConfig schemaRegistryConfig
Field Value
| Type | Description |
|---|---|
| SchemaRegistryConfig |
Properties
RequiresSchemaRegistryClient
Whether the serde being built requires a Schema Registry client.
True for every serializer, and for deserializers that must look up the writer schema. Overridden to false by the deserializers that can work from the schema of the target type alone, for which supplying no client is a valid choice.
Declaration
protected virtual bool RequiresSchemaRegistryClient { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
ConstructSerde<TSerde>(Func<ISchemaRegistryClient, TSerde>, Action<TSerde>, Func<TSerde, Task>)
Construct the serde around the resolved Schema Registry client, handing the client's ownership to the serde when it was constructed here.
A serde constructor that throws - on an unknown configuration parameter, say - would otherwise leak the client just constructed, since nothing else holds a reference to it yet.
Declaration
protected TSerde ConstructSerde<TSerde>(Func<ISchemaRegistryClient, TSerde> construct, Action<TSerde> ownSchemaRegistryClient, Func<TSerde, Task> init = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<ISchemaRegistryClient, TSerde> | construct | Constructs the serde from the client. |
| Action<TSerde> | ownSchemaRegistryClient | Makes the serde take ownership of its client, so that the client is disposed along with it. Invoked only when the client was constructed here. |
| Func<TSerde, Task> | init | Optional setup run to completion on the constructed serde, for anything the builder's setters do not cover. If it throws, the serde's owned resources are released before the exception propagates. It runs before the serde has been handed the cluster id resolver, so it must not serialize or deserialize. |
Returns
| Type | Description |
|---|---|
| TSerde |
Type Parameters
| Name | Description |
|---|---|
| TSerde |
ResolveSchemaRegistryClient(out bool)
Resolve the Schema Registry client to construct the serde with, constructing one if the application did not supply one.
Declaration
protected ISchemaRegistryClient ResolveSchemaRegistryClient(out bool owned)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | owned | Whether the returned client was constructed here, and must therefore be disposed along with the serde. |
Returns
| Type | Description |
|---|---|
| ISchemaRegistryClient |
SetRuleRegistry(RuleRegistry)
The rule registry to construct the serde with. Defaults to the global instance.
Declaration
public TBuilder SetRuleRegistry(RuleRegistry ruleRegistry)
Parameters
| Type | Name | Description |
|---|---|---|
| RuleRegistry | ruleRegistry |
Returns
| Type | Description |
|---|---|
| TBuilder |
SetSchemaRegistryClient(ISchemaRegistryClient)
Use a Schema Registry client constructed by the application.
The client is not disposed along with the serde - its lifetime remains the application's responsibility.
Declaration
public TBuilder SetSchemaRegistryClient(ISchemaRegistryClient schemaRegistryClient)
Parameters
| Type | Name | Description |
|---|---|---|
| ISchemaRegistryClient | schemaRegistryClient |
Returns
| Type | Description |
|---|---|
| TBuilder |
SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder)
Construct the Schema Registry client with the given builder.
Use this when the client needs more than configuration alone, such as an authentication header value provider or a proxy - refer to CachedSchemaRegistryClientBuilder. The client is owned by the serde, and is disposed along with it.
Declaration
public TBuilder SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder schemaRegistryClientBuilder)
Parameters
| Type | Name | Description |
|---|---|---|
| ISchemaRegistryClientBuilder | schemaRegistryClientBuilder |
Returns
| Type | Description |
|---|---|
| TBuilder |
SetSchemaRegistryConfig(SchemaRegistryConfig)
Construct the Schema Registry client from the given configuration.
The client is owned by the serde, and is disposed along with it. Use SetSchemaRegistryClientBuilder(ISchemaRegistryClientBuilder) instead when the client also needs an authentication header value provider or a proxy.
Declaration
public TBuilder SetSchemaRegistryConfig(SchemaRegistryConfig schemaRegistryConfig)
Parameters
| Type | Name | Description |
|---|---|---|
| SchemaRegistryConfig | schemaRegistryConfig |
Returns
| Type | Description |
|---|---|
| TBuilder |