Interface ISchemaRegistryClient
Provides schema registry operations for schema management in message serialization.
public interface ISchemaRegistryClient
- Extension Methods
Remarks
This interface is transport-agnostic to support multiple schema registry implementations:
- Confluent Schema Registry (implemented)
- AWS Glue Schema Registry (future)
- Azure Schema Registry (future)
Implementations should be registered as singletons and are expected to be thread-safe.
Methods
GetSchemaByIdAsync(int, CancellationToken)
Gets the schema definition for a given schema ID.
Task<string> GetSchemaByIdAsync(int schemaId, CancellationToken cancellationToken)
Parameters
schemaIdintThe schema ID to retrieve.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Exceptions
- SchemaRegistryException
Thrown when the schema ID is not found or the registry is unavailable.
GetSchemaIdAsync(string, string, CancellationToken)
Gets the schema ID for a given subject and schema definition.
Task<int> GetSchemaIdAsync(string subject, string schema, CancellationToken cancellationToken)
Parameters
subjectstringThe schema subject (typically topic-key or topic-value).
schemastringThe schema definition (JSON, Avro, Protobuf).
cancellationTokenCancellationTokenThe cancellation token.
Returns
Exceptions
- SchemaRegistryException
Thrown when the schema cannot be found or the registry is unavailable.
IsCompatibleAsync(string, string, CancellationToken)
Checks if a schema is compatible with the latest version under the specified subject.
Task<bool> IsCompatibleAsync(string subject, string schema, CancellationToken cancellationToken)
Parameters
subjectstringThe schema subject to check compatibility against.
schemastringThe schema definition to validate.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Exceptions
- SchemaRegistryException
Thrown when the compatibility check fails or the registry is unavailable.
RegisterSchemaAsync(string, string, CancellationToken)
Registers a new schema under the specified subject.
Task<int> RegisterSchemaAsync(string subject, string schema, CancellationToken cancellationToken)
Parameters
subjectstringThe schema subject (typically topic-key or topic-value).
schemastringThe schema definition to register.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Exceptions
- SchemaRegistryException
Thrown when the schema registration fails or the registry is unavailable.