Class: Async::IO::CompositeEndpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/async/io/composite_endpoint.rb

Instance Attribute Summary

Attributes inherited from Endpoint

#options

Instance Method Summary collapse

Methods inherited from Endpoint

#accept, #bound, composite, #connected, each, #hostname, #linger, #local_address, parse, #reuse_address, #reuse_port, socket, ssl, tcp, #timeout, try_convert, udp, unix, #with

Constructor Details

#initialize(endpoints, **options) ⇒ CompositeEndpoint

Returns a new instance of CompositeEndpoint.



11
12
13
14
# File 'lib/async/io/composite_endpoint.rb', line 11

def initialize(endpoints, **options)
  super(**options)
  @endpoints = endpoints
end

Instance Method Details

#bind(&block) ⇒ Object



33
34
35
# File 'lib/async/io/composite_endpoint.rb', line 33

def bind(&block)
  @endpoints.map(&:bind)
end

#connect(&block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/async/io/composite_endpoint.rb', line 20

def connect(&block)
  error = nil
  
  @endpoints.each do |endpoint|
    begin
      return endpoint.connect(&block)
    rescue => error
    end
  end
  
  raise error
end

#each(&block) ⇒ Object



16
17
18
# File 'lib/async/io/composite_endpoint.rb', line 16

def each(&block)
  @endpoints.each(&block)
end