Class: RubyEventStore::Outbox::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/outbox/cli.rb

Defined Under Namespace

Classes: Options, Parser

Constant Summary collapse

DEFAULTS =
{
  database_url: nil,
  redis_url: nil,
  log_level: :warn,
  split_keys: nil,
  message_format: "sidekiq5",
  batch_size: 100,
  metrics_url: nil,
  cleanup_strategy: :none,
  cleanup_limit: :all,
  sleep_on_empty: 0.5,
  locking: true,
}

Instance Method Summary collapse

Instance Method Details

#build_runner(options) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ruby_event_store/outbox/cli.rb', line 106

def build_runner(options)
  consumer_uuid = SecureRandom.uuid
  logger = Logger.new(STDOUT, level: options.log_level, progname: "RES-Outbox #{consumer_uuid}")
  consumer_configuration =
    Configuration.new(
      split_keys: options.split_keys,
      message_format: options.message_format,
      batch_size: options.batch_size,
      database_url: options.database_url,
      redis_url: options.redis_url,
      cleanup: options.cleanup_strategy,
      cleanup_limit: options.cleanup_limit,
      sleep_on_empty: options.sleep_on_empty,
      locking: options.locking,
    )
  metrics = Metrics.from_url(options.metrics_url)
  outbox_consumer = Outbox::Consumer.new(consumer_uuid, consumer_configuration, logger: logger, metrics: metrics)
  Runner.new(outbox_consumer, consumer_configuration, logger: logger)
end

#run(argv) ⇒ Object



101
102
103
104
# File 'lib/ruby_event_store/outbox/cli.rb', line 101

def run(argv)
  options = Parser.parse(argv)
  build_runner(options).run
end