Class: NATS::MonotonicTime

Inherits:
Object
  • Object
show all
Defined in:
lib/nats/io/client.rb

Class Method Summary collapse

Class Method Details

.since(t0) ⇒ Object



2045
2046
2047
# File 'lib/nats/io/client.rb', line 2045

def since(t0)
  now - t0
end

.with_nats_timeout(timeout) ⇒ Object



2035
2036
2037
2038
2039
2040
2041
2042
2043
# File 'lib/nats/io/client.rb', line 2035

def with_nats_timeout(timeout)
  start_time = now
  yield
  end_time = now
  duration = end_time - start_time
  if duration > timeout
    raise NATS::Timeout.new("nats: timeout")
  end
end