module Avromatic
Constants
- VERSION
Attributes
allow_unknown_attributes[RW]
custom_type_registry[RW]
logger[RW]
messaging[RW]
nested_models[RW]
registry_url[RW]
schema_registry[RW]
schema_store[RW]
use_custom_datum_reader[RW]
use_custom_datum_writer[RW]
use_schema_fingerprint_lookup[RW]
Public Class Methods
build_messaging()
click to toggle source
# File lib/avromatic.rb, line 52 def self.build_messaging raise 'Avromatic must be configured with a schema_store' unless schema_store Avromatic::Messaging.new( registry: schema_registry || build_schema_registry, schema_store: schema_store, logger: logger ) end
build_messaging!()
click to toggle source
# File lib/avromatic.rb, line 62 def self.build_messaging! self.messaging = build_messaging end
build_schema_registry()
click to toggle source
# File lib/avromatic.rb, line 34 def self.build_schema_registry raise 'Avromatic must be configured with a registry_url' unless registry_url if use_schema_fingerprint_lookup AvroSchemaRegistry::CachedClient.new( AvroSchemaRegistry::Client.new(registry_url, logger: logger) ) else AvroTurf::CachedConfluentSchemaRegistry.new( AvroTurf::ConfluentSchemaRegistry.new(registry_url, logger: logger) ) end end
build_schema_registry!()
click to toggle source
# File lib/avromatic.rb, line 48 def self.build_schema_registry! self.schema_registry = build_schema_registry end
configure() { |self| ... }
click to toggle source
# File lib/avromatic.rb, line 30 def self.configure yield self end
eager_load_models()
click to toggle source
# File lib/avromatic.rb, line 85 def self.eager_load_models @eager_load_model_names end
eager_load_models=(models)
click to toggle source
# File lib/avromatic.rb, line 81 def self.eager_load_models=(models) @eager_load_model_names = Array(models).map { |model| model.is_a?(Class) ? model.name : model }.freeze end
prepare!()
click to toggle source
This method is called as a Rails to_prepare hook after the application first initializes during boot-up and prior to each code reloading.
# File lib/avromatic.rb, line 68 def self.prepare! nested_models.clear if schema_store if schema_store.respond_to?(:clear_schemas) schema_store.clear_schemas elsif schema_store.respond_to?(:clear) schema_store.clear end end eager_load_models! end
Private Class Methods
eager_load_models!()
click to toggle source
# File lib/avromatic.rb, line 89 def self.eager_load_models! @eager_load_model_names&.each { |model_name| model_name.constantize.register! } end