Sha256: 3ec0612c4dae75944a93bff0cc3a403c1bee8f6f3d242d190a1e6f13a6c35b62

Contents?: true

Size: 1.05 KB

Versions: 55

Compression:

Stored size: 1.05 KB

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.to_s, schema_name: schema)
      end

      # @override
      def encode_payload(payload, schema: nil, topic: nil)
        avro_turf_messaging.encode(payload, schema_name: schema, subject: topic || schema)
      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,
          user: Deimos.config.schema.user,
          password: Deimos.config.schema.password,
          namespace: @namespace,
          logger: Deimos.config.logger
        )
      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.24.1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.24.0 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.3 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.23.0 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22.5 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22.4 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22.3 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22.2 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22.1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.22 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.20.1 lib/deimos/schema_backends/avro_schema_registry.rb
deimos-ruby-1.20.0 lib/deimos/schema_backends/avro_schema_registry.rb