Class: DispatchPolicy::Decision

Inherits:
Object
  • Object
show all
Defined in:
lib/dispatch_policy/decision.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed:, retry_after: nil, gate_state_patch: nil, reason: nil) ⇒ Decision

Returns a new instance of Decision.



7
8
9
10
11
12
# File 'lib/dispatch_policy/decision.rb', line 7

def initialize(allowed:, retry_after: nil, gate_state_patch: nil, reason: nil)
  @allowed           = allowed
  @retry_after       = retry_after
  @gate_state_patch  = gate_state_patch
  @reason            = reason
end

Instance Attribute Details

#allowedObject (readonly)

Returns the value of attribute allowed.



5
6
7
# File 'lib/dispatch_policy/decision.rb', line 5

def allowed
  @allowed
end

#gate_state_patchObject (readonly)

Returns the value of attribute gate_state_patch.



5
6
7
# File 'lib/dispatch_policy/decision.rb', line 5

def gate_state_patch
  @gate_state_patch
end

#reasonObject (readonly)

Returns the value of attribute reason.



5
6
7
# File 'lib/dispatch_policy/decision.rb', line 5

def reason
  @reason
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



5
6
7
# File 'lib/dispatch_policy/decision.rb', line 5

def retry_after
  @retry_after
end

Class Method Details

.deny(retry_after: nil, reason: nil) ⇒ Object



18
19
20
# File 'lib/dispatch_policy/decision.rb', line 18

def self.deny(retry_after: nil, reason: nil)
  new(allowed: 0, retry_after: retry_after, reason: reason)
end

.unlimitedObject



14
15
16
# File 'lib/dispatch_policy/decision.rb', line 14

def self.unlimited
  new(allowed: Float::INFINITY)
end