Table of Contents

Interface ISchemaResolver<S, T>

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

Defines a contract for resolving schemas from a schema registry for serialization and deserialization operations. This interface provides asynchronous schema resolution capabilities with support for both artifact reference-based and record-based schema lookup strategies.

public interface ISchemaResolver<S, T> : IDisposable

Type Parameters

S

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

T

The data type that will be serialized/deserialized using resolved schemas

Inherited Members

Remarks

ISchemaResolver is the central component for schema registry integration, responsible for fetching, parsing, and caching schemas from a schema registry service. It supports multiple resolution strategies to accommodate different serialization scenarios and provides efficient async operations with cancellation support.

The resolver maintains connections to the schema registry and manages the lifecycle of schema parsing operations. Implementations should handle caching, error recovery, and resource cleanup appropriately. Always dispose of resolver instances to ensure proper cleanup of registry connections and resources.

Properties

SchemaParser

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

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, including schema registry connection details and authentication credentials.

void Configure(IDictionary<string, object> properties)

Parameters

properties IDictionary<string, object>

A dictionary containing configuration properties for the schema resolver

Remarks

This method establishes the connection to the schema registry and initializes the resolver with configuration settings such as registry URL, authentication credentials, SSL settings, and caching options. The method should be called once before performing any schema resolution operations.

The properties dictionary typically includes settings from SchemaResolverProperties or derived configuration classes. Invalid or missing required properties should result in configuration exceptions.

Exceptions

ArgumentException

Thrown when required configuration properties are missing or invalid

InvalidOperationException

Thrown when the resolver is already configured or cannot establish registry connection

ResolveSchemaAsync(IRecord<T>, CancellationToken)

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

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.

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