Class: OMQ::Transport::IPC::Dialer

Inherits:
Object
  • Object
show all
Defined in:
lib/omq/transport/ipc.rb

Overview

An IPC dialer — stateful factory for outgoing connections.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, engine) ⇒ Dialer

Returns a new instance of Dialer.

Parameters:

  • endpoint (String)
  • engine (Engine)


102
103
104
105
# File 'lib/omq/transport/ipc.rb', line 102

def initialize(endpoint, engine)
  @endpoint = endpoint
  @engine   = engine
end

Instance Attribute Details

#endpointString (readonly)

Returns the endpoint this dialer connects to.

Returns:

  • (String)

    the endpoint this dialer connects to



96
97
98
# File 'lib/omq/transport/ipc.rb', line 96

def endpoint
  @endpoint
end

Instance Method Details

#connectvoid

This method returns an undefined value.

Establishes a Unix socket connection to the endpoint.



112
113
114
115
116
117
118
# File 'lib/omq/transport/ipc.rb', line 112

def connect
  path      = IPC.parse_path(@endpoint)
  sock_path = IPC.to_socket_path(path)
  sock      = UNIXSocket.new(sock_path)
  IPC.apply_buffer_sizes(sock, @engine.options)
  @engine.handle_connected(IO::Stream::Buffered.wrap(sock), endpoint: @endpoint)
end