Class: Bidi2pdf::Bidi::ConnectionManager
- Inherits:
-
Object
- Object
- Bidi2pdf::Bidi::ConnectionManager
- Defined in:
- lib/bidi2pdf/bidi/connection_manager.rb
Instance Method Summary collapse
-
#initialize(logger:) ⇒ ConnectionManager
constructor
A new instance of ConnectionManager.
- #mark_connected ⇒ Object
-
#wait_until_open(timeout:) ⇒ Object
rubocop:disable Naming/PredicateMethod.
Constructor Details
#initialize(logger:) ⇒ ConnectionManager
Returns a new instance of ConnectionManager.
6 7 8 9 10 |
# File 'lib/bidi2pdf/bidi/connection_manager.rb', line 6 def initialize(logger:) @logger = logger @connected = false @connection_latch = Concurrent::CountDownLatch.new(1) end |
Instance Method Details
#mark_connected ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bidi2pdf/bidi/connection_manager.rb', line 12 def mark_connected return if @connected @connected = true @logger.debug "WebSocket connection is open" @connection_latch.count_down end |
#wait_until_open(timeout:) ⇒ Object
rubocop:disable Naming/PredicateMethod
21 22 23 24 25 26 27 28 29 |
# File 'lib/bidi2pdf/bidi/connection_manager.rb', line 21 def wait_until_open(timeout:) return true if @connected @logger.debug "Waiting for WebSocket connection to open" raise Bidi2pdf::WebsocketError, "WebSocket connection did not open in time #{timeout} sec." unless @connection_latch.wait(timeout) true end |