Table of Contents

Class DefaultSchemaResolver<S, T>

Namespace
Solace.SchemaRegistry.Serdes.Core.Resolver
Assembly
Solace.SchemaRegistry.Serdes.Core.dll

Default implementation of ISchemaResolver<S, T> that provides schema resolution capabilities for serialization operations using a schema registry.

public class DefaultSchemaResolver<S, T> : ISchemaResolver<S, T>, IDisposable

Type Parameters

S

The schema type that this resolver handles (e.g., JsonSchema)

T

The data type that will be serialized using resolved schemas

Inheritance
DefaultSchemaResolver<S, T>
Implements
Inherited Members

Remarks

This resolver uses an IArtifactReferenceResolverStrategy<T, S> to determine artifact coordinates from record data, then resolves the schema from the registry using those coordinates.

The resolver communicates with the schema registry via Solace.SchemaRegistry.Serdes.Core.Resolver.Client.ISchemaRegistryClient and uses ISchemaParser<S> to parse raw schema bytes into strongly-typed schema objects.

Constructors

DefaultSchemaResolver()

Constructs a DefaultSchemaResolver.

public DefaultSchemaResolver()

Properties

SchemaParser

Gets or sets the schema parser used for converting raw schema bytes into strongly-typed schema objects.

public ISchemaParser<S> SchemaParser { get; set; }

Property Value

ISchemaParser<S>

An ISchemaParser<S> implementation that can parse schemas of type S. Must be set before performing schema resolution operations.

Remarks

The schema parser is responsible for format-specific parsing of schema artifacts retrieved from the schema registry. Different schema formats (AVRO, JSON Schema, etc.) require different parsers. The resolver uses this parser to convert raw schema bytes into usable schema objects.

The parser should be set during resolver initialization and should remain consistent throughout the resolver's lifetime to ensure proper schema handling and type safety.

Exceptions

ArgumentNullException

Thrown when attempting to set a null parser

Methods

Configure(IDictionary<string, object>)

Configures the schema resolver with the specified properties.

public void Configure(IDictionary<string, object> properties)

Parameters

properties IDictionary<string, object>

A dictionary containing configuration properties for the schema resolver

Exceptions

ArgumentException

Thrown when required configuration properties are missing or invalid

Dispose()

public void Dispose()

Dispose(bool)

Disposes this schema resolver and releases any system resources associated with it.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources

ResolveSchemaAsync(IRecord<T>, CancellationToken)

Asynchronously resolves a schema using the specified record data to determine the appropriate schema.

public ValueTask<ISchemaLookupResult<S>> ResolveSchemaAsync(IRecord<T> record, CancellationToken token = default)

Parameters

record IRecord<T>

The record containing the data and metadata to use for schema resolution

token CancellationToken

A cancellation token that can be used to cancel the resolution operation

Returns

ValueTask<ISchemaLookupResult<S>>

A task that represents the asynchronous resolution operation, containing an ISchemaLookupResult<S> with the resolved schema and artifact information.

Remarks

This method resolves schemas when no explicit artifact reference is available, typically during serialization operations where the schema must be determined from the data structure or metadata. The resolver uses configured strategies to determine the appropriate schema for the given record.

The resolution process may involve analyzing the record structure, consulting metadata headers, applying resolution strategies, and potentially registering new schemas if they don't exist. The specific behavior depends on the configured artifact reference resolver strategy.

Exceptions

ArgumentNullException

Thrown when record is null

InvalidOperationException

Thrown when the resolver is not properly configured

OperationCanceledException

Thrown when the operation is canceled via the cancellation token

SerializationException

Thrown when schema resolution or registration fails

ResolveSchemaAsync(IArtifactReference, CancellationToken)

Asynchronously resolves a schema using the specified artifact reference.

public ValueTask<ISchemaLookupResult<S>> ResolveSchemaAsync(IArtifactReference artifactReference, CancellationToken token = default)

Parameters

artifactReference IArtifactReference

The artifact reference that identifies the schema to resolve

token CancellationToken

A cancellation token that can be used to cancel the resolution operation

Returns

ValueTask<ISchemaLookupResult<S>>

A task that represents the asynchronous resolution operation, containing an ISchemaLookupResult<S> with the resolved schema and artifact information.

Remarks

This method resolves schemas when the artifact reference is already known, typically during deserialization operations where the schema identifier is embedded in the data. The resolver fetches the schema from the registry, parses it using the configured parser, and returns the complete lookup result.

The resolution process may involve registry API calls, caching lookups, and schema parsing. Implementations should handle network errors, caching strategies, and parsing failures appropriately.

Exceptions

ArgumentNullException

Thrown when artifactReference is null

InvalidOperationException

Thrown when the resolver is not properly configured

OperationCanceledException

Thrown when the operation is canceled via the cancellation token

SerializationException

Thrown when the referenced schema cannot be found or parsed

See Also