Module: MessageBusClient::Connection
- Included in:
- Client
- Defined in:
- lib/message_bus_client/connection.rb
Constant Summary collapse
- INITIALISED =
The connection is in the initialised state.
0
- STARTED =
The connection is in the started state.
1
- PAUSED =
The connection is in the paused state.
2
- STOPPING =
The connection is in the stopping state.
3
- STOPPED =
The connection is in the stopped state.
4
Instance Method Summary collapse
- #diagnostics ⇒ Object
- #initialize(base_url) ⇒ Object
- #pause ⇒ Object
- #paused? ⇒ Boolean
- #resume ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #stopped? ⇒ Boolean
Instance Method Details
#diagnostics ⇒ Object
26 27 |
# File 'lib/message_bus_client/connection.rb', line 26 def diagnostics end |
#initialize(base_url) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/message_bus_client/connection.rb', line 17 def initialize(base_url) @connection = nil @runner = nil @base_url = base_url @state = INITIALISED @statistics = { total_calls: 0, failed_calls: 0 } end |
#pause ⇒ Object
38 39 40 41 42 |
# File 'lib/message_bus_client/connection.rb', line 38 def pause return unless @state == STARTED @state = PAUSED end |
#paused? ⇒ Boolean
44 45 46 |
# File 'lib/message_bus_client/connection.rb', line 44 def paused? @state == PAUSED end |
#resume ⇒ Object
48 49 50 51 52 53 |
# File 'lib/message_bus_client/connection.rb', line 48 def resume return unless @state == PAUSED @state = STARTED end |
#start ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/message_bus_client/connection.rb', line 29 def start return unless @state == INITIALISED || stopped? @state = STARTED @connection = Excon.new(server_endpoint, persistent: true) @runner = Thread.new { runner } @runner.abort_on_exception = true end |
#stop ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/message_bus_client/connection.rb', line 55 def stop return unless @state == STARTED || @state == PAUSED @state = STOPPING @connection.reset @runner.join end |
#stopped? ⇒ Boolean
63 64 65 |
# File 'lib/message_bus_client/connection.rb', line 63 def stopped? @state == STOPPED end |