Class: Cassandra::Retry::Policies::Backoff

Inherits:
Object
  • Object
show all
Includes:
Cassandra::Retry::Policy
Defined in:
lib/logstash/outputs/cassandra/backoff_retry_policy.rb

Overview

This is a version of the default retry policy (github.com/datastax/ruby-driver/blob/v2.1.5/lib/cassandra/retry/policies/default.rb) with backoff retry configuration options

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Backoff

Returns a new instance of Backoff.



12
13
14
15
16
17
# File 'lib/logstash/outputs/cassandra/backoff_retry_policy.rb', line 12

def initialize(opts)
  @logger = opts['logger']
  @backoff_type = opts['backoff_type']
  @backoff_size = opts['backoff_size']
  @retry_limit = opts['retry_limit']
end

Instance Method Details

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



19
20
21
22
# File 'lib/logstash/outputs/cassandra/backoff_retry_policy.rb', line 19

def read_timeout(statement, consistency, required, received, retrieved, retries)
  retry_with_backoff({ :statement => statement, :consistency => consistency, :required => required,
                       :received => received, :retrieved => retrieved, :retries => retries })
end

#retry_with_backoff(opts) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/logstash/outputs/cassandra/backoff_retry_policy.rb', line 34

def retry_with_backoff(opts)
  if @retry_limit > -1 && opts[:retries] > @retry_limit
    @logger.error('backoff retries exhausted', :opts => opts)
    return reraise
  end

  @logger.error('activating backoff wait', :opts => opts)
  backoff_wait_before_next_retry(opts[:retries])

  try_again(opts[:consistency])
end

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



29
30
31
32
# File 'lib/logstash/outputs/cassandra/backoff_retry_policy.rb', line 29

def unavailable(statement, consistency, required, alive, retries)
  retry_with_backoff({ :statement => statement, :consistency => consistency, :required => required,
                       :alive => alive, :retries => retries })
end

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



24
25
26
27
# File 'lib/logstash/outputs/cassandra/backoff_retry_policy.rb', line 24

def write_timeout(statement, consistency, type, required, received, retries)
  retry_with_backoff({ :statement => statement, :consistency => consistency, :type => type,
                       :required => required, :received => received, :retries => retries })
end