Class: TShield::GrpcCounter
- Inherits:
-
Object
- Object
- TShield::GrpcCounter
- Defined in:
- lib/tshield/grpc/grpc_counter.rb
Overview
Increment counter for sessions requests
Instance Method Summary collapse
- #add(hexdigest) ⇒ Object
- #current(hexdigest) ⇒ Object
-
#initialize ⇒ GrpcCounter
constructor
A new instance of GrpcCounter.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ GrpcCounter
Returns a new instance of GrpcCounter.
6 7 8 |
# File 'lib/tshield/grpc/grpc_counter.rb', line 6 def initialize @requests = {} end |
Instance Method Details
#add(hexdigest) ⇒ Object
10 11 12 13 14 |
# File 'lib/tshield/grpc/grpc_counter.rb', line 10 def add(hexdigest) count = @requests.fetch(hexdigest, 0) count += 1 @requests[hexdigest] = count end |
#current(hexdigest) ⇒ Object
16 17 18 |
# File 'lib/tshield/grpc/grpc_counter.rb', line 16 def current(hexdigest) @requests.fetch(hexdigest, 0) end |
#to_json(options = {}) ⇒ Object
20 21 22 |
# File 'lib/tshield/grpc/grpc_counter.rb', line 20 def to_json( = {}) @requests.to_json() end |