Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (42 sloc) 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.

You can’t perform that action at this time.