Class: PulsarSdk::Client::Connection::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/pulsar_sdk/client/connection.rb

Constant Summary collapse

STATUS =
%w[
  init
  connecting
  tcp_connected
  ready
  closed
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatus

Returns a new instance of Status.



300
301
302
303
304
305
306
# File 'lib/pulsar_sdk/client/connection.rb', line 300

def initialize
  @state = 'init'
  @lock = Mutex.new
  @signal = ConditionVariable.new
  @last_received_at = 0
  @last_ping_at = 0
end

Instance Attribute Details

#last_ping_atObject (readonly)

Returns the value of attribute last_ping_at.



290
291
292
# File 'lib/pulsar_sdk/client/connection.rb', line 290

def last_ping_at
  @last_ping_at
end

#last_received_atObject (readonly)

Returns the value of attribute last_received_at.



290
291
292
# File 'lib/pulsar_sdk/client/connection.rb', line 290

def last_received_at
  @last_received_at
end

Instance Method Details

#ping!Object



320
321
322
323
324
# File 'lib/pulsar_sdk/client/connection.rb', line 320

def ping!
  @lock.synchronize do
    @last_ping_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  end
end

#received!Object



314
315
316
317
318
# File 'lib/pulsar_sdk/client/connection.rb', line 314

def received!
  @lock.synchronize do
    @last_received_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  end
end

#waitObject



308
309
310
311
312
# File 'lib/pulsar_sdk/client/connection.rb', line 308

def wait
  @lock.synchronize do
    @signal.wait(@lock)
  end
end