Class: LittleGhost::AgentStreamSink

Inherits:
Object
  • Object
show all
Defined in:
lib/little_ghost/agent_stream_source.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initialize(destination:, run:, source:, input:) ⇒ AgentStreamSink

Returns a new instance of AgentStreamSink.



242
243
244
245
246
247
# File 'lib/little_ghost/agent_stream_source.rb', line 242

def initialize(destination:, run:, source:, input:)
  @destination = destination
  @run = run
  @source = source
  @input = input
end

Instance Method Details

#<<(event) ⇒ Object



249
250
251
252
253
254
# File 'lib/little_ghost/agent_stream_source.rb', line 249

def <<(event)
  data = {source: @source, event: AgentStreamSnapshot.event(event)}
  data[:input] = AgentStreamSnapshot.message(normalized_input) if event.type == :invocation_start
  @run.publish(:agent_stream, **data)
  @destination << event
end