Sha256: 6c17f52a5ffa871bec694599f06ea983c9f4a5830ac81b96b11079c2ce57fc67

Contents?: true

Size: 922 Bytes

Versions: 20

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require_relative 'avro_base'
require_relative 'avro_validation'
require 'avro_turf/messaging'

module Deimos
  module SchemaBackends
    # Encode / decode using the Avro schema registry.
    class AvroSchemaRegistry < AvroBase
      # @override
      def decode_payload(payload, schema:)
        avro_turf_messaging.decode(payload, schema_name: schema)
      end

      # @override
      def encode_payload(payload, schema: nil, topic: nil)
        avro_turf_messaging.encode(payload, schema_name: schema, subject: topic)
      end

    private

      # @return [AvroTurf::Messaging]
      def avro_turf_messaging
        @avro_turf_messaging ||= AvroTurf::Messaging.new(
          schema_store: @schema_store,
          registry_url: Deimos.config.schema.registry_url,
          schemas_path: Deimos.config.schema.path,
          namespace: @namespace
        )
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
deimos-ruby-1.8.2.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta9 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta8 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta7 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta6 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta5 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta4 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta3 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.1.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.0.pre.beta2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.8.0.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.7.0.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.4 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.3 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.0 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.6.0.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.5.0.pre.beta2 lib/deimos/schema_backends/avro_schema_registry.rb