Method: MessageBus::Backends::Redis#initialize

Defined in:
lib/message_bus/backends/redis.rb

#initialize(redis_config = {}, max_backlog_size = 1000) ⇒ Redis

Returns a new instance of Redis.

Parameters:

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

    in addition to the options listed, see github.com/redis/redis-rb for other available options

  • max_backlog_size (Integer) (defaults to: 1000)

    the largest permitted size (number of messages) for per-channel backlogs; beyond this capacity, old messages will be dropped.

Options Hash (redis_config):

  • :logger (Logger)

    a logger to which logs will be output

  • :enable_redis_logger (Boolean) — default: false

    whether or not to enable logging by the underlying Redis library

  • :clear_every (Integer) — default: 1

    the interval of publications between which the backlog will not be cleared



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/message_bus/backends/redis.rb', line 48

def initialize(redis_config = {}, max_backlog_size = 1000)
  @redis_config = redis_config.dup
  @clear_every = redis_config.delete(:clear_every) || 1
  @logger = @redis_config[:logger]
  unless @redis_config[:enable_redis_logger]
    @redis_config[:logger] = nil
  end
  @max_backlog_size = max_backlog_size
  @max_global_backlog_size = 2000
  @max_in_memory_publish_backlog = 1000
  @in_memory_backlog = []
  @lock = Mutex.new
  @flush_backlog_thread = nil
  @pub_redis = nil
  @subscribed = false
  # after 7 days inactive backlogs will be removed
  @max_backlog_age = 604800
end