module Rafka

Constants

REDIS_DEFAULTS
RETRIABLE_ERRORS

Server errors upon which we should retry the operation.

VERSION

Public Class Methods

with_retry(max_retries=15) { || ... } click to toggle source

Retries the operation upon Redis::CommandError

# File lib/rafka.rb, line 32
def self.with_retry(max_retries=15)
  retries = 0

  begin
    yield
  rescue Redis::CommandError => e
    if RETRIABLE_ERRORS.include?(e.message) && retries < max_retries
      sleep 1
      retries += 1
      retry
    end

    raise e
  end
end
wrap_errors() { || ... } click to toggle source

Wraps errors from redis-rb to our own error classes

# File lib/rafka.rb, line 23
def self.wrap_errors
  yield
rescue Redis::CommandError => e
  raise ProduceError, e.message[5..-1] if e.message.start_with?("PROD ")
  raise ConsumeError, e.message[5..-1] if e.message.start_with?("CONS ")
  raise CommandError, e.message
end