Class: AnyCable::Rack::RPC::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/anycable/rack/rpc/client.rb

Overview

AnyCable RPC client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Returns a new instance of Client.



12
13
14
# File 'lib/anycable/rack/rpc/client.rb', line 12

def initialize(host)
  @stub = AnyCable::RPC::Service.rpc_stub_class.new(host, :this_channel_is_insecure)
end

Instance Attribute Details

#stubObject (readonly)

Returns the value of attribute stub.



10
11
12
# File 'lib/anycable/rack/rpc/client.rb', line 10

def stub
  @stub
end

Instance Method Details

#command(command:, identifier:, connection_identifiers:, data:) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/anycable/rack/rpc/client.rb', line 21

def command(command:, identifier:, connection_identifiers:, data:)
  message = CommandMessage.new(
    command: command,
    identifier: identifier,
    connection_identifiers: connection_identifiers,
    data: data
  )
  stub.command(message)
end

#connect(headers:, path:) ⇒ Object



16
17
18
19
# File 'lib/anycable/rack/rpc/client.rb', line 16

def connect(headers:, path:)
  request = ConnectionRequest.new(headers: headers, path: path)
  stub.connect(request)
end

#disconnect(identifiers:, subscriptions:, headers:, path:) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/anycable/rack/rpc/client.rb', line 31

def disconnect(identifiers:, subscriptions:, headers:, path:)
  request = DisconnectRequest.new(
    identifiers: identifiers,
    subscriptions: subscriptions,
    headers: headers,
    path: path
  )
  stub.disconnect(request)
end