This library provides an interface (ISchemaSink
) and an abstract class (SchemaSink
) for schema registry so that other third-party sink providers follow the same design principles.
Currently, there are three official sinks available:
Package | Download | Version |
---|---|---|
Aliencube.AzureMessaging.SchemaRegistry.Sinks |
When you plan to build a new sink, by extending SchemaSink
, the new sink SHOULD target both net461
and netestandard2.0
.
As an interface, and as an abstract class, both ISchemaSink
and SchemaSink
declare the following properties and methods:
BaseLocation
: Declares the base location where the sink is located. Default isstring.Empty
.WithBaseLocation(string location)
: Adds the base location where the sink is located.GetSchemaAsync(string path)
: Gets the JSON schema from the schema registry.SetSchemaAsync(string schema, string path)
: Sets the JSON schema to the given path in the schema registry.
As SchemaSink
is an abstract class, this MUST be inherited by other sinks. There are a few considerations when extending SchemaSink
:
SchemaSink
has two constructors – one without parameters and the other withstring location
that takes the base location of the sink. Therefore,- A new sink extending
SchemaSink
SHOULD implement both constructors, or - The new sink MUST implement at least the one with the
string location
parameter.
- A new sink extending
- The new sink extending
SchemaSink
SHOULD override bothGetSchemaAsync(string)
andSetSchemaAsync(string, string)
for further processing.
public class FakeSchemaSink : SchemaSink
{
public FakeSchemaSink()
{
}
public FakeSchemaSink(string location)
: base(location)
{
}
public override async Task<string> GetSchemaAsync(string path)
{
// Implement logic here
return schema;
}
public override async Task<bool> SetSchemaAsync(string schema, string path)
{
// Implement logic here
return true;
}
}