Class: Cassandra::Retry::Policies::DowngradingConsistency

Inherits:
Object
  • Object
show all
Includes:
Cassandra::Retry::Policy
Defined in:
lib/cassandra/retry/policies/downgrading_consistency.rb

Instance Method Summary collapse

Instance Method Details

#read_timeout(statement, consistency, required, received, retrieved, retries) ⇒ Object



25
26
27
28
29
30
# File 'lib/cassandra/retry/policies/downgrading_consistency.rb', line 25

def read_timeout(statement, consistency, required, received, retrieved, retries)
  return reraise if retries > 0 || SERIAL_CONSISTENCIES.include?(consistency)
  return max_likely_to_work(consistency, required, received) if received < required

  retrieved ? reraise : try_again(consistency)
end

#unavailable(statement, consistency, required, alive, retries) ⇒ Object



47
48
49
50
51
# File 'lib/cassandra/retry/policies/downgrading_consistency.rb', line 47

def unavailable(statement, consistency, required, alive, retries)
  return reraise if retries > 0

  max_likely_to_work(consistency, required, alive)
end

#write_timeout(statement, consistency, type, required, received, retries) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cassandra/retry/policies/downgrading_consistency.rb', line 32

def write_timeout(statement, consistency, type, required, received, retries)
  return reraise if retries > 0

  case type
  when :simple, :batch
    ignore
  when :unlogged_batch
    max_likely_to_work(consistency, required, received)
  when :batch_log
    try_again(consistency)
  else
    reraise
  end
end