Class CachedSchemaRegistryClient
A caching Schema Registry client.
The following method calls cache results:
- GetSchemaIdAsync(string, Schema, bool)
- GetSchemaIdAsync(string, string, bool)
- GetSchemaAsync(int, string)
- GetSchemaBySubjectAndIdAsync(string, int, string)
- RegisterSchemaAsync(string, Schema, bool)
- RegisterSchemaAsync(string, string, bool)
- CachedSchemaRegistryClient.GetRegisteredSchemaAsync(string, int)
The following method calls do NOT cache results:
Inherited Members
Namespace: Confluent.SchemaRegistry
Assembly: Confluent.SchemaRegistry.dll
Syntax
public class CachedSchemaRegistryClient : ISchemaRegistryClient, IDisposable
Constructors
CachedSchemaRegistryClient(IEnumerable<KeyValuePair<string, string>>)
Initialize a new instance of the SchemaRegistryClient class.
Declaration
public CachedSchemaRegistryClient(IEnumerable<KeyValuePair<string, string>> config)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<string, string>> | config | Configuration properties. |
CachedSchemaRegistryClient(IEnumerable<KeyValuePair<string, string>>, IAuthenticationHeaderValueProvider)
Initialize a new instance of the SchemaRegistryClient class with a custom IAuthenticationHeaderValueProvider
Declaration
public CachedSchemaRegistryClient(IEnumerable<KeyValuePair<string, string>> config, IAuthenticationHeaderValueProvider authenticationHeaderValueProvider)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<string, string>> | config | Configuration properties. |
IAuthenticationHeaderValueProvider | authenticationHeaderValueProvider | The authentication header value provider |
Fields
DefaultEnableSslCertificateVerification
The default SSL server certificate verification for Schema Registry REST API calls.
Declaration
public const bool DefaultEnableSslCertificateVerification = true
Field Value
Type | Description |
---|---|
bool |
DefaultKeySubjectNameStrategy
The default key subject name strategy.
Declaration
public const SubjectNameStrategy DefaultKeySubjectNameStrategy = Topic
Field Value
Type | Description |
---|---|
SubjectNameStrategy |
DefaultLatestCacheTtlSecs
The default TTL for caches holding latest schemas.
Declaration
public const int DefaultLatestCacheTtlSecs = -1
Field Value
Type | Description |
---|---|
int |
DefaultMaxCachedSchemas
The default maximum capacity of the local schema cache.
Declaration
public const int DefaultMaxCachedSchemas = 1000
Field Value
Type | Description |
---|---|
int |
DefaultTimeout
The default timeout value for Schema Registry REST API calls.
Declaration
public const int DefaultTimeout = 30000
Field Value
Type | Description |
---|---|
int |
DefaultValueSubjectNameStrategy
The default value subject name strategy.
Declaration
public const SubjectNameStrategy DefaultValueSubjectNameStrategy = Topic
Field Value
Type | Description |
---|---|
SubjectNameStrategy |
Properties
Config
The client config.
Declaration
public IEnumerable<KeyValuePair<string, string>> Config { get; }
Property Value
Type | Description |
---|---|
IEnumerable<KeyValuePair<string, string>> |
MaxCachedSchemas
The maximum capacity of the local schema cache.
Declaration
public int MaxCachedSchemas { get; }
Property Value
Type | Description |
---|---|
int |
Methods
ClearCaches()
Clears all caches.
Declaration
public void ClearCaches()
ClearLatestCaches()
Clears caches of latest versions.
Declaration
public void ClearLatestCaches()
ConstructKeySubjectName(string, string)
DEPRECATED. SubjectNameStrategy should now be specified via serializer configuration. Returns the schema registry key subject name given a topic name.
Declaration
[Obsolete("SubjectNameStrategy should now be specified via serializer configuration. This method will be removed in a future release.")]
public string ConstructKeySubjectName(string topic, string recordType = null)
Parameters
Type | Name | Description |
---|---|---|
string | topic | The topic name. |
string | recordType | The fully qualified record type. May be null if not required by the configured subject naming strategy. |
Returns
Type | Description |
---|---|
string | The key subject name given a topic name. |
ConstructValueSubjectName(string, string)
DEPRECATED. SubjectNameStrategy should now be specified via serializer configuration. Returns the schema registry value subject name given a topic name.
Declaration
[Obsolete("SubjectNameStrategy should now be specified via serializer configuration. This method will be removed in a future release.")]
public string ConstructValueSubjectName(string topic, string recordType = null)
Parameters
Type | Name | Description |
---|---|---|
string | topic | The topic name. |
string | recordType | The fully qualified record type. May be null if not required by the configured subject naming strategy. |
Returns
Type | Description |
---|---|
string | The value subject name given a topic name. |
Dispose()
Releases unmanaged resources owned by this CachedSchemaRegistryClient instance.
Declaration
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by this object and optionally disposes the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
GetAllSubjectsAsync()
Gets a list of all subjects with registered schemas.
Declaration
public Task<List<string>> GetAllSubjectsAsync()
Returns
Type | Description |
---|---|
Task<List<string>> | A list of all subjects with registered schemas. |
GetCompatibilityAsync(string)
If the subject is specified returns compatibility type for the specified subject. Otherwise returns global compatibility type.
Declaration
public Task<Compatibility> GetCompatibilityAsync(string subject = null)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get the compatibility for. |
Returns
Type | Description |
---|---|
Task<Compatibility> | Compatibility type. |
GetLatestSchemaAsync(string)
Get the latest schema registered against the specified subject
.
Declaration
public Task<RegisteredSchema> GetLatestSchemaAsync(string subject)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get the latest associated schema for. |
Returns
Type | Description |
---|---|
Task<RegisteredSchema> | The latest schema registered against |
GetLatestWithMetadataAsync(string, IDictionary<string, string>, bool)
Get the latest schema with the given metadata registered against the specified subject
.
Declaration
public Task<RegisteredSchema> GetLatestWithMetadataAsync(string subject, IDictionary<string, string> metadata, bool ignoreDeletedSchemas)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get the latest associated schema for. |
IDictionary<string, string> | metadata | |
bool | ignoreDeletedSchemas |
Returns
Type | Description |
---|---|
Task<RegisteredSchema> | The latest schema with the given metadata registered against |
GetRegisteredSchemaAsync(string, int, bool)
Gets a schema given a subject
and version
number.
Declaration
public Task<RegisteredSchema> GetRegisteredSchemaAsync(string subject, int version, bool ignoreDeletedSchemas = true)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get the schema for. |
int | version | The version number of schema to get. |
bool | ignoreDeletedSchemas | Whether or not to ignore deleted schemas. |
Returns
Type | Description |
---|---|
Task<RegisteredSchema> | The schema identified by the specified |
GetSchemaAsync(int, string)
Gets the schema uniquely identified by id
.
Declaration
public Task<Schema> GetSchemaAsync(int id, string format = null)
Parameters
Type | Name | Description |
---|---|---|
int | id | The unique id of schema to get. |
string | format | The format of the schema to get. Currently, the only supported value is "serialized", and this is only valid for protobuf schemas. If 'serialized', the SchemaString property of the returned value will be a base64 encoded protobuf file descriptor. If null, SchemaString will be human readable text. |
Returns
Type | Description |
---|---|
Task<Schema> | The schema identified by |
GetSchemaAsync(string, int)
DEPRECATED. Superseded by GetRegisteredSchemaAsync(string subject, int version)
Gets a schema given a subject
and version
number.
Declaration
[Obsolete("Superseded by GetRegisteredSchemaAsync(string subject, int version). This method will be removed in a future release.")]
public Task<string> GetSchemaAsync(string subject, int version)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get the schema for. |
int | version | The version number of schema to get. |
Returns
Type | Description |
---|---|
Task<string> | The schema identified by the specified |
GetSchemaBySubjectAndIdAsync(string, int, string)
Declaration
public Task<Schema> GetSchemaBySubjectAndIdAsync(string subject, int id, string format = null)
Parameters
Type | Name | Description |
---|---|---|
string | subject | |
int | id | |
string | format |
Returns
Type | Description |
---|---|
Task<Schema> |
GetSchemaIdAsync(string, Schema, bool)
Get the unique id of the specified schema registered against the specified subject.
Declaration
public Task<int> GetSchemaIdAsync(string subject, Schema schema, bool normalize = false)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject the schema is registered against. |
Schema | schema | The schema to get the id for. |
bool | normalize | Whether to normalize schemas. |
Returns
Type | Description |
---|---|
Task<int> | The unique id identifying the schema. |
Exceptions
Type | Condition |
---|---|
SchemaRegistryException | Thrown if the schema is not registered against the subject. |
GetSchemaIdAsync(string, string, bool)
Get the unique id of the specified avro schema registered against the specified subject.
Declaration
public Task<int> GetSchemaIdAsync(string subject, string avroSchema, bool normalize = false)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject the schema is registered against. |
string | avroSchema | The schema to get the id for. |
bool | normalize | Whether to normalize schemas. |
Returns
Type | Description |
---|---|
Task<int> | The unique id identifying the schema. |
Exceptions
Type | Condition |
---|---|
SchemaRegistryException | Thrown if the schema is not registered against the subject. |
GetSubjectVersionsAsync(string)
Gets a list of versions registered under the specified subject
.
Declaration
public Task<List<int>> GetSubjectVersionsAsync(string subject)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to get versions registered under. |
Returns
Type | Description |
---|---|
Task<List<int>> | A list of versions registered under the specified |
IsCompatibleAsync(string, Schema)
Check if a schema is compatible with latest version registered against a specified subject.
Declaration
public Task<bool> IsCompatibleAsync(string subject, Schema schema)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to check. |
Schema | schema | The schema to check. |
Returns
Type | Description |
---|---|
Task<bool> | true if |
IsCompatibleAsync(string, string)
Check if an avro schema is compatible with latest version registered against a specified subject.
Declaration
public Task<bool> IsCompatibleAsync(string subject, string avroSchema)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to check. |
string | avroSchema | The schema to check. |
Returns
Type | Description |
---|---|
Task<bool> | true if |
LookupSchemaAsync(string, Schema, bool, bool)
Get the registered schema details (including version and id) given a subject name and schema, or throw an exception if the schema is not registered against the subject.
Declaration
public Task<RegisteredSchema> LookupSchemaAsync(string subject, Schema schema, bool ignoreDeletedSchemas, bool normalize = false)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject name the schema is registered against. |
Schema | schema | The schema to lookup. |
bool | ignoreDeletedSchemas | Whether or not to ignore deleted schemas. |
bool | normalize | Whether to normalize schemas. |
Returns
Type | Description |
---|---|
Task<RegisteredSchema> | The schema identified by the specified |
RegisterSchemaAsync(string, Schema, bool)
Register a schema or get the schema id if it's already registered.
Declaration
public Task<int> RegisterSchemaAsync(string subject, Schema schema, bool normalize = false)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to register the schema against. |
Schema | schema | The schema to register. |
bool | normalize | Whether to normalize schemas. |
Returns
Type | Description |
---|---|
Task<int> | A unique id identifying the schema. |
RegisterSchemaAsync(string, string, bool)
Register an Avro schema or get the schema id if it's already registered.
Declaration
public Task<int> RegisterSchemaAsync(string subject, string avroSchema, bool normalize = false)
Parameters
Type | Name | Description |
---|---|---|
string | subject | The subject to register the schema against. |
string | avroSchema | The schema to register. |
bool | normalize | Whether to normalize schemas. |
Returns
Type | Description |
---|---|
Task<int> | A unique id identifying the schema. |
UpdateCompatibilityAsync(Compatibility, string)
If the subject is specified sets compatibility type for the specified subject. Otherwise sets global compatibility type.
Declaration
public Task<Compatibility> UpdateCompatibilityAsync(Compatibility compatibility, string subject = null)
Parameters
Type | Name | Description |
---|---|---|
Compatibility | compatibility | Compatibility type. |
string | subject | The subject to set the compatibility for. |
Returns
Type | Description |
---|---|
Task<Compatibility> | New compatibility type. |