Class: Jbr::Retriable

Inherits:
Error
  • Object
show all
Defined in:
lib/jbr/retriable.rb

Overview

Jobber refusing a query over what it costs rather than over anything about the query. The bucket it is priced against refills, so the same question asked later is answered.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, cost = {}) ⇒ Retriable

Returns a new instance of Retriable.

Parameters:

  • message (String)

    what Jobber said, with the numbers it said it with.

  • cost (Hash) (defaults to: {})

    the requestedQueryCost and the throttleStatus beside it.



7
8
9
10
11
12
13
14
# File 'lib/jbr/retriable.rb', line 7

def initialize(message, cost = {})
  super message
  status = cost['throttleStatus'].to_h
  @cost = cost['requestedQueryCost']
  @available = status['currentlyAvailable']
  @maximum = status['maximumAvailable']
  @restore_rate = status['restoreRate']
end

Instance Attribute Details

#availableObject (readonly)

What the query would have cost, the budget it was priced against, and how fast that budget refills. A cost above the maximum is one no waiting will pay for.



18
19
20
# File 'lib/jbr/retriable.rb', line 18

def available
  @available
end

#costObject (readonly)

What the query would have cost, the budget it was priced against, and how fast that budget refills. A cost above the maximum is one no waiting will pay for.



18
19
20
# File 'lib/jbr/retriable.rb', line 18

def cost
  @cost
end

#maximumObject (readonly)

What the query would have cost, the budget it was priced against, and how fast that budget refills. A cost above the maximum is one no waiting will pay for.



18
19
20
# File 'lib/jbr/retriable.rb', line 18

def maximum
  @maximum
end

#restore_rateObject (readonly)

What the query would have cost, the budget it was priced against, and how fast that budget refills. A cost above the maximum is one no waiting will pay for.



18
19
20
# File 'lib/jbr/retriable.rb', line 18

def restore_rate
  @restore_rate
end