Module: Phobos
- 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/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, Constants, Handler, Instrumentation, Log, LoggerHelper, Processor, Producer, Test Classes: AbortError, BatchMessage, DeepStruct, EchoHandler, Error, Executor, Listener
Constant Summary collapse
- VERSION =
'1.8.2'
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
-
.silence_log ⇒ Object
Returns the value of attribute silence_log.
Class Method Summary collapse
- .add_listeners(configuration) ⇒ Object
- .configure(configuration) ⇒ Object
-
.configure_logger ⇒ Object
:nodoc:.
- .create_exponential_backoff(backoff_config = nil) ⇒ Object
- .create_kafka_client ⇒ Object
- .deprecate(message) ⇒ Object
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
53 54 55 |
# File 'lib/phobos.rb', line 53 def config @config end |
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
53 54 55 |
# File 'lib/phobos.rb', line 53 def logger @logger end |
.silence_log ⇒ Object
Returns the value of attribute silence_log.
54 55 56 |
# File 'lib/phobos.rb', line 54 def silence_log @silence_log end |
Class Method Details
.add_listeners(configuration) ⇒ Object
64 65 66 67 |
# File 'lib/phobos.rb', line 64 def add_listeners(configuration) listeners_config = fetch_configuration(configuration) @config.listeners += listeners_config.listeners end |
.configure(configuration) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/phobos.rb', line 56 def configure(configuration) @config = fetch_configuration(configuration) @config.class.send(:define_method, :producer_hash) { Phobos.config.producer&.to_hash } @config.class.send(:define_method, :consumer_hash) { Phobos.config.consumer&.to_hash } @config.listeners ||= [] configure_logger end |
.configure_logger ⇒ Object
:nodoc:
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/phobos.rb', line 85 def configure_logger Logging.backtrace(true) Logging.logger.root.level = silence_log ? :fatal : config.logger.level configure_ruby_kafka_logger configure_phobos_logger logger.info do Hash(message: 'Phobos configured', env: ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'N/A') end end |
.create_exponential_backoff(backoff_config = nil) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/phobos.rb', line 73 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 ⇒ Object
69 70 71 |
# File 'lib/phobos.rb', line 69 def create_kafka_client Kafka.new(config.kafka.to_hash.merge(logger: @ruby_kafka_logger)) end |
.deprecate(message) ⇒ Object
80 81 82 |
# File 'lib/phobos.rb', line 80 def deprecate() warn "DEPRECATION WARNING: #{} #{Kernel.caller.first}" end |