Class: Gruf::Interceptors::Timer
- Inherits:
-
Object
- Object
- Gruf::Interceptors::Timer
- Defined in:
- lib/gruf/interceptors/timer.rb
Overview
Utility class that can be used by interceptors to time requests
Defined Under Namespace
Classes: Result
Class Method Summary collapse
-
.time ⇒ Gruf::Interceptors::Timer::Result
Time a given code block and return a Timer::Result object.
Class Method Details
.time ⇒ Gruf::Interceptors::Timer::Result
Time a given code block and return a Timer::Result object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gruf/interceptors/timer.rb', line 79 def self.time start_time = Time.now = yield end_time = Time.now elapsed = (end_time - start_time) * 1000.0 Result.new(, elapsed, true) rescue GRPC::BadStatus => e end_time = Time.now elapsed = (end_time - start_time) * 1000.0 Result.new(e, elapsed, false) end |