Skip to content

Latest commit

 

History

History
47 lines (31 loc) · 1.89 KB

schema-registry-sinks-file-system.md

File metadata and controls

47 lines (31 loc) · 1.89 KB

Schema Registry Sink for Local File System

This library provides a sink class to local file system that is used for the schema registry.

NuGet Package Status

Package Download Version
Aliencube.AzureMessaging.SchemaRegistry.Sinks.FileSystem

Usage

IFileSystemSchemaSink and FileSystemSchemaSink

As an extension of ISchemaSink and SchemaSink respectively, both IFileSystemSchemaSink and FileSystemSchemaSink declare extra properties:

  • Directory: Gets or sets the IDirectoryWrapper instance. Default is DirectoryWrapper.
  • File: Gets or sets the IFileWrapper instance. Default is FileWrapper.
  • Encoding: Gets or sets the file encoding. Default is Encoding.UTF8.

It also has two overriding methods, GetSchemaAsync(string path) and SetSchemaAsync(string schema, string path).

var location = "/etc/schema-registry/";

var sink = new FileSystemSchemaSink()
               .WithBaseLocation(location);

var schema = "{" +
             "  \"type\": \"object\"," +
             "  \"properties\": {" +
             "    \"hello\": {" +
             "      \"type\": \"string\"" +
             "    }" +
             "  }" +
             "}";

var path = "v1/schema.json";

var sinked = await sink.SetSchemaAsync(schema, path)
                       .ConfigureAwait(false);

var schema = await sink.GetSchemaAsync(path)
                       .ConfigureAwait(false);