Class: OMQ::Transport::TCP::Dialer
- Inherits:
-
Object
- Object
- OMQ::Transport::TCP::Dialer
- Defined in:
- lib/omq/transport/tcp.rb
Overview
A TCP dialer — stateful factory for outgoing connections.
Created once per Engine#connect, stored in @dialers. Reconnect calls #connect directly — no transport lookup or opts replay needed.
Instance Attribute Summary collapse
-
#endpoint ⇒ String
readonly
The endpoint this dialer connects to.
Instance Method Summary collapse
-
#connect ⇒ void
Establishes a TCP connection to the endpoint.
-
#initialize(endpoint, engine) ⇒ Dialer
constructor
A new instance of Dialer.
Constructor Details
#initialize(endpoint, engine) ⇒ Dialer
Returns a new instance of Dialer.
159 160 161 162 |
# File 'lib/omq/transport/tcp.rb', line 159 def initialize(endpoint, engine) @endpoint = endpoint @engine = engine end |
Instance Attribute Details
#endpoint ⇒ String (readonly)
Returns the endpoint this dialer connects to.
153 154 155 |
# File 'lib/omq/transport/tcp.rb', line 153 def endpoint @endpoint end |
Instance Method Details
#connect ⇒ void
This method returns an undefined value.
Establishes a TCP connection to the endpoint.
169 170 171 172 173 174 175 |
# File 'lib/omq/transport/tcp.rb', line 169 def connect host, port = TCP.parse_endpoint(@endpoint) host = TCP.normalize_connect_host(host) sock = ::Socket.tcp(host, port, connect_timeout: TCP.connect_timeout(@engine.)) TCP.apply_buffer_sizes(sock, @engine.) @engine.handle_connected(IO::Stream::Buffered.wrap(sock), endpoint: @endpoint) end |