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



1975
1976
1977
# File 'lib/nats/io/client.rb', line 1975

def since(t0)
  now - t0
end

.with_nats_timeout(timeout) ⇒ Object



1965
1966
1967
1968
1969
1970
1971
1972
1973
# File 'lib/nats/io/client.rb', line 1965

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