Module: Phobos

Extended by:
Configuration
Defined in:
lib/phobos/deep_struct.rb,
lib/phobos.rb,
lib/phobos/cli.rb,
lib/phobos/log.rb,
lib/phobos/errors.rb,
lib/phobos/handler.rb,
lib/phobos/version.rb,
lib/phobos/executor.rb,
lib/phobos/listener.rb,
lib/phobos/producer.rb,
lib/phobos/cli/start.rb,
lib/phobos/constants.rb,
lib/phobos/processor.rb,
lib/phobos/cli/runner.rb,
lib/phobos/test/helper.rb,
lib/phobos/echo_handler.rb,
lib/phobos/batch_handler.rb,
lib/phobos/batch_message.rb,
lib/phobos/configuration.rb,
lib/phobos/instrumentation.rb,
lib/phobos/actions/process_batch.rb,
lib/phobos/actions/process_message.rb,
lib/phobos/actions/process_batch_inline.rb

Overview

Please use this with at least the same consideration as you would when using OpenStruct. Right now we only use this to parse our internal configuration files. It is not meant to be used on incoming data.

Defined Under Namespace

Modules: Actions, BatchHandler, CLI, Configuration, Constants, Handler, Instrumentation, Log, LoggerHelper, Processor, Producer, Test Classes: AbortError, BatchMessage, DeepStruct, EchoHandler, Error, Executor, Listener

Constant Summary collapse

VERSION =
'2.1.3'

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Configuration

configure, configure_logger

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



54
55
56
# File 'lib/phobos.rb', line 54

def config
  @config
end

.loggerObject (readonly)

Returns the value of attribute logger.



54
55
56
# File 'lib/phobos.rb', line 54

def logger
  @logger
end

.silence_logObject

Returns the value of attribute silence_log.



55
56
57
# File 'lib/phobos.rb', line 55

def silence_log
  @silence_log
end

Class Method Details

.add_listeners(configuration) ⇒ Object



57
58
59
60
# File 'lib/phobos.rb', line 57

def add_listeners(configuration)
  listeners_config = fetch_configuration(configuration)
  @config.listeners += listeners_config.listeners
end

.create_exponential_backoff(backoff_config = nil) ⇒ Object



72
73
74
75
76
77
# File 'lib/phobos.rb', line 72

def create_exponential_backoff(backoff_config = nil)
  backoff_config ||= Phobos.config.backoff.to_hash
  min = backoff_config[:min_ms] / 1000.0
  max = backoff_config[:max_ms] / 1000.0
  ExponentialBackoff.new(min, max).tap { |backoff| backoff.randomize_factor = rand }
end

.create_kafka_client(config_key = nil) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/phobos.rb', line 62

def create_kafka_client(config_key = nil)
  kafka_config = config.kafka.to_hash.merge(logger: @ruby_kafka_logger)

  if config_key
    kafka_config = kafka_config.merge(**config.send(config_key)&.kafka&.to_hash || {})
  end

  Kafka.new(**kafka_config)
end

.deprecate(message) ⇒ Object



79
80
81
82
# File 'lib/phobos.rb', line 79

def deprecate(message)
  location = caller.find { |line| line !~ %r{/phobos/} }
  warn "DEPRECATION WARNING: #{message}: #{location}"
end