Class: Deimos::SchemaBackends::AvroSchemaRegistry
- Defined in:
- lib/deimos/schema_backends/avro_schema_registry.rb
Overview
Encode / decode using the Avro schema registry.
Instance Attribute Summary
Attributes inherited from AvroBase
Attributes inherited from Base
#key_schema, #namespace, #schema
Instance Method Summary collapse
- #decode_payload(payload, schema:) ⇒ Object
- #encode_payload(payload, schema: nil, topic: nil) ⇒ Object
Methods inherited from AvroBase
#coerce_field, content_type, #decode_key, #encode_key, field_type, #generate_key_schema, #initialize, #load_schema, mock_backend, schema_base_class, schema_classname, #schema_fields, #sql_type, #validate
Methods inherited from Base
#coerce, #coerce_field, content_type, #decode, #decode_key, #encode, #encode_key, field_type, #generate_key_schema, #initialize, #load_schema, mock_backend, #schema_fields, #sql_type, #validate
Constructor Details
This class inherits a constructor from Deimos::SchemaBackends::AvroBase
Instance Method Details
#decode_payload(payload, schema:) ⇒ Object
11 12 13 |
# File 'lib/deimos/schema_backends/avro_schema_registry.rb', line 11 def decode_payload(payload, schema:) avro_turf_messaging.decode(payload.to_s, schema_name: schema) end |
#encode_payload(payload, schema: nil, topic: nil) ⇒ Object
16 17 18 |
# File 'lib/deimos/schema_backends/avro_schema_registry.rb', line 16 def encode_payload(payload, schema: nil, topic: nil) avro_turf_messaging.encode(payload, schema_name: schema, subject: topic || schema) end |