Class: TShield::GrpcCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/tshield/grpc/grpc_counter.rb

Overview

Increment counter for sessions requests

Instance Method Summary collapse

Constructor Details

#initializeGrpcCounter

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(options = {})
  @requests.to_json(options)
end