Class: AgUi::Server::RecordingBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ag_ui/server.rb

Overview

Wraps the StreamBuilder so opened runs record into the store.

Instance Method Summary collapse

Constructor Details

#initialize(builder, store) ⇒ RecordingBuilder

Returns a new instance of RecordingBuilder.



163
164
165
166
# File 'lib/ag_ui/server.rb', line 163

def initialize(builder, store)
  @builder = builder
  @store = store
end

Instance Method Details

#open(thread_id:, run_id:, validate: true, &block) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/ag_ui/server.rb', line 168

def open(thread_id:, run_id:, validate: true, &block)
  @store.begin_run(thread_id, run_id)

  @builder.open(
    thread_id: thread_id,
    run_id:    run_id,
    validate:  validate,
    on_event:  ->(payload) { @store.record(thread_id, payload) },
    on_finish: -> { @store.finish_run(thread_id) },
    on_task:   ->(task) { @store.attach_task(thread_id, task) },
    &block
  )
end