Skip to content
Kward Search API index

Class: Kward::Transport::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/transport/runtime.rb

Overview

Builds the Kward runtime needed by foreground transport processes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Runtime

Returns a new instance of Runtime.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kward/transport/runtime.rb', line 14

def initialize(client:)
  @server = RPC::Server.new(
    input: StringIO.new,
    output: StringIO.new,
    error_output: $stderr,
    client: client
  )
  @manager = Manager.new(
    registry: @server.session_manager.plugin_registry,
    gateway: lambda { |transport_id|
      Gateway.new(session_manager: @server.session_manager, transport_id: transport_id)
    },
    plugin_chat_gateway: lambda { |transport_id|
      PluginChatGateway.new(runtime: @server.plugin_chat_manager.runtime, transport_id: transport_id)
    },
    config_root: ConfigFiles.config_dir,
    config_provider: ->(transport_id) { ConfigFiles.transport_config(transport_id) }
  )
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



12
13
14
# File 'lib/kward/transport/runtime.rb', line 12

def manager
  @manager
end

Instance Method Details

#shutdownObject



34
35
36
37
38
# File 'lib/kward/transport/runtime.rb', line 34

def shutdown
  @manager.shutdown
  @server.shutdown
  nil
end