Class: Mihari::Enrichers::Base
- Includes:
- MemoWise
- Defined in:
- lib/mihari/enrichers/base.rb
Overview
Base class for enrichers
Direct Known Subclasses
Constant Summary
Constants included from Concerns::Retriable
Concerns::Retriable::DEFAULT_CONDITION, Concerns::Retriable::RETRIABLE_ERRORS
Instance Attribute Summary
Attributes inherited from Actor
Class Method Summary collapse
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(options: nil) ⇒ Base
constructor
A new instance of Base.
- #result(value) ⇒ Dry::Monads::Result::Success<Object>, Dry::Monads::Result::Failure
Methods inherited from Actor
key, key_aliases, keys, #retry_exponential_backoff, #retry_interval, #retry_times, #timeout, type, #validate_configuration!
Methods included from Concerns::Retriable
Methods included from Concerns::Configurable
#configuration_keys?, #configured?
Constructor Details
#initialize(options: nil) ⇒ Base
Returns a new instance of Base.
11 12 13 |
# File 'lib/mihari/enrichers/base.rb', line 11 def initialize(options: nil) super(options: ) end |
Class Method Details
.inherited(child) ⇒ Object
44 45 46 47 |
# File 'lib/mihari/enrichers/base.rb', line 44 def inherited(child) super Mihari.enrichers << child end |
Instance Method Details
#call(value) ⇒ Object
18 19 20 |
# File 'lib/mihari/enrichers/base.rb', line 18 def call(value) raise NotImplementedError, "You must implement #{self.class}##{__method__}" end |
#result(value) ⇒ Dry::Monads::Result::Success<Object>, Dry::Monads::Result::Failure
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mihari/enrichers/base.rb', line 27 def result(value) result = Try[StandardError] do retry_on_error( times: retry_times, interval: retry_interval, exponential_backoff: retry_exponential_backoff ) { call value } end.to_result if result.failure? Mihari.logger.warn("Enricher:#{self.class.key} for #{value.truncate(32)} failed: #{result.failure}") end result end |