Class: A2A::Server::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent_card:, executor:, storage: Storage::Memory.new, push_sender: nil, host: "localhost", port: 9292) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/simple_a2a/server/base.rb', line 8

def initialize(
  agent_card:,
  executor:,
  storage:      Storage::Memory.new,
  push_sender:  nil,
  host:         "localhost",
  port:         9292
)
  @agent_card   = agent_card
  @executor     = executor
  @storage      = storage
  @event_router = EventRouter.new
  @push_sender  = push_sender
  @host         = host
  @port         = port
end

Instance Attribute Details

#agent_cardObject (readonly)

Returns the value of attribute agent_card.



6
7
8
# File 'lib/simple_a2a/server/base.rb', line 6

def agent_card
  @agent_card
end

#event_routerObject (readonly)

Returns the value of attribute event_router.



6
7
8
# File 'lib/simple_a2a/server/base.rb', line 6

def event_router
  @event_router
end

#executorObject (readonly)

Returns the value of attribute executor.



6
7
8
# File 'lib/simple_a2a/server/base.rb', line 6

def executor
  @executor
end

#push_senderObject (readonly)

Returns the value of attribute push_sender.



6
7
8
# File 'lib/simple_a2a/server/base.rb', line 6

def push_sender
  @push_sender
end

#storageObject (readonly)

Returns the value of attribute storage.



6
7
8
# File 'lib/simple_a2a/server/base.rb', line 6

def storage
  @storage
end

Instance Method Details

#rack_appObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/simple_a2a/server/base.rb', line 25

def rack_app
  klass = Class.new(App)
  klass.configure(
    agent_card:   @agent_card,
    storage:      @storage,
    executor:     @executor,
    event_router: @event_router,
    push_sender:  @push_sender
  )
  klass.freeze.app
end

#runObject



37
38
39
40
# File 'lib/simple_a2a/server/base.rb', line 37

def run
  app = rack_app
  FalconRunner.new(app, host: @host, port: @port).run
end