Sha256: 1dc7c180c31ca4ad06e414908c9a97715001233de3d54dbdc18803a2bab6719e

Contents?: true

Size: 1.04 KB

Versions: 9

Compression:

Stored size: 1.04 KB

Contents

require 'avromatic/version'
require 'avromatic/model'
require 'avro_turf'
require 'avro_turf/messaging'

module Avromatic
  class << self
    attr_accessor :schema_registry, :registry_url, :schema_store, :logger,
                  :messaging, :type_registry

    delegate :register_type, to: :type_registry
  end

  self.logger = Logger.new($stdout)
  self.type_registry = Avromatic::Model::TypeRegistry.new

  def self.configure
    yield self
  end

  def self.build_schema_registry
    raise 'Avromatic must be configured with a registry_url' unless registry_url
    AvroTurf::CachedSchemaRegistry.new(
      AvroTurf::SchemaRegistry.new(registry_url, logger: logger)
    )
  end

  def self.build_messaging
    raise 'Avromatic must be configured with a schema_store' unless schema_store
    AvroTurf::Messaging.new(
      registry: schema_registry || build_schema_registry,
      schema_store: schema_store,
      logger: logger
    )
  end

  def self.build_messaging!
    self.messaging = build_messaging
  end
end

require 'avromatic/railtie' if defined?(Rails)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avromatic-0.9.0.rc1 lib/avromatic.rb
avromatic-0.9.0.rc0 lib/avromatic.rb
avromatic-0.8.0 lib/avromatic.rb
avromatic-0.7.1 lib/avromatic.rb
avromatic-0.7.0 lib/avromatic.rb
avromatic-0.6.2 lib/avromatic.rb
avromatic-0.6.1 lib/avromatic.rb
avromatic-0.6.0 lib/avromatic.rb
avromatic-0.5.0 lib/avromatic.rb