Class: GlassOctopus::Middleware::AvroParser

Inherits:
Object
  • Object
show all
Defined in:
lib/glass_octopus/middleware/avro_parser.rb

Defined Under Namespace

Classes: ContextWithAvroParsedMessage

Instance Method Summary collapse

Constructor Details

#initialize(app, schema_registry_url, options = {}) ⇒ AvroParser

Returns a new instance of AvroParser.



12
13
14
15
# File 'lib/glass_octopus/middleware/avro_parser.rb', line 12

def initialize(app, schema_registry_url, options={})
  @app = app
  @decoder = AvroTurf::Messaging.new(registry_url: schema_registry_url, logger: options[:logger])
end

Instance Method Details

#call(ctx) ⇒ Object



17
18
19
20
21
# File 'lib/glass_octopus/middleware/avro_parser.rb', line 17

def call(ctx)
  message = @decoder.decode(ctx.message.value)
  ctx = ContextWithAvroParsedMessage.new(ctx, message)
  @app.call(ctx)
end