Sha256: dfcb5da955cf19bb03f21c161807f42df481df14fcd3b82ebf818d862003178b
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
# frozen_string_literal: true module Mihari # # Base class for Analyzer, Emitter and Enricher # class Actor < Service include Mixins::Configurable include Mixins::Retriable # @return [Hash] attr_reader :options # # @param [Hash, nil] options # def initialize(options: nil) super() @options = options || {} end # # @return [Integer] # def retry_interval options[:retry_interval] || Mihari.config.retry_interval end # # @return [Boolean] # def retry_exponential_backoff options[:retry_exponential_backoff] || Mihari.config.retry_exponential_backoff end # # @return [Integer] # def retry_times options[:retry_times] || Mihari.config.retry_times end # # @return [Integer, nil] # def timeout options[:timeout] end def validate_configuration! return if configured? joined = configuration_keys.join(", ") be = (configuration_keys.length > 1) ? "are" : "is" message = "#{self.class.class_key} is not configured correctly. #{joined} #{be} missing." raise ConfigurationError, message end def result Try[StandardError] do retry_on_error( times: retry_times, interval: retry_interval, exponential_backoff: retry_exponential_backoff ) { call } end.to_result end class << self # # @return [String] # def class_key to_s.split("::").last end # # @return [Array<String>, nil] # def class_key_aliases nil end # # @return [Array<String>] # def class_keys ([class_key] + [class_key_aliases]).flatten.compact.map(&:downcase) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.7.0 | lib/mihari/actor.rb |