Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 2.54 KB

schema-registry.md

File metadata and controls

66 lines (42 loc) · 2.54 KB

Schema Registry

This is a schema registry library to produce a JSON schema and upload it to a registry, or download the JSON schema from the registry and consume it. Schema registry is accessible through SchemaSink.

NuGet Package Status

Package Download Version
Aliencube.AzureMessaging.SchemaRegistry

Usage

SchemaProducer

SchemaProducer creates a JSON schema and uploads it to given sinks. Currently, there are three official sinks available:

You can register as many sinks as you want, if you plan to duplicate sink locations. The following sample code shows how SchemaProducer uploads the schema through three different sinks.

var settings = new JsonSchemaGeneratorSettings();
var builder = new SchemaBuilder().WithSettings(settings);

var sink1 = new FileSystemSchemaSink();
var sink2 = new HttpSchemaSink();
var sink3 = new BlobStorageSchemaSink();

var version = "v1";
var filename = "schema.json";
var path = $"{version}/{filename}";

var producer = new SchemaProducer()
                   .WithBuilder(builder)
                   .WithSink(sink1)
                   .WithSink(sink2)
                   .WithSink(sink3);

var produced = await producer.ProduceAsync<SampleClass>(path).ConfigureAwait(false);

Note: This code deliberately omits how each sink is configured. For more details how it works, go to each sink page.

SchemaConsumer

SchemaConsumer downloads a JSON schema from the given sink. Unlike SchemaProducer, it can only uses one SchemaSink at one time.

var sink = new BlobStorageSchemaSink();

var version = "v1";
var filename = "schema.json";
var path = $"{version}/{filename}";

var consumer = new SchemaConsumer()
                   .WithSink(sink);

var schema = await consumer.ConsumeAsync(path).ConfigureAwait(false);

Note: This code deliberately omits how each sink is configured. For more details on how it works, go to each sink page.