class Avrolution::RegisterSchemas
Attributes
schema_files[R]
Public Class Methods
new(schema_files)
click to toggle source
# File lib/avrolution/register_schemas.rb, line 22 def initialize(schema_files) @schema_files = Array(schema_files) @compatibility_breaks = Avrolution::CompatibilityBreaksFile.load @schema_registry = build_schema_registry end
Public Instance Methods
call()
click to toggle source
# File lib/avrolution/register_schemas.rb, line 28 def call schemas.each do |(json, schema)| register_schema(schema, json) end end
Private Instance Methods
build_schema_registry()
click to toggle source
# File lib/avrolution/register_schemas.rb, line 62 def build_schema_registry AvroSchemaRegistry::Client.new(Avrolution.deployment_schema_registry_url, logger: Avrolution.logger) end
register_schema(schema, json)
click to toggle source
# File lib/avrolution/register_schemas.rb, line 36 def register_schema(schema, json) fullname = schema.fullname fingerprint = schema.sha256_resolution_fingerprint.to_s(16) compatibility_break = compatibility_breaks[[fullname, fingerprint]] begin schema_registry.register_without_lookup( fullname, json, compatibility_break.try(:register_options) || {} ) rescue Excon::Error::Conflict raise IncompatibleSchemaError.new(fullname) end end
schemas()
click to toggle source
# File lib/avrolution/register_schemas.rb, line 53 def schemas @schemas ||= schema_files.map do |schema_file| if File.exist?(schema_file) json = File.read(schema_file) [json, Avro::Schema.parse(json)] end end.compact end