Sha256: 887edeccee229101d0ec3f03d8d3776812e612223f07aef1d19f916730a3f993
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Mihari module Emitters class Base < Mihari::Base include Dry::Monads[:result, :try] include Mixins::Configurable include Mixins::Retriable # @return [Array<Mihari::Artifact>] attr_reader :artifacts # @return [Mihari::Services::Rule] attr_reader :rule # # @param [Array<Mihari::Artifact>] artifacts # @param [Mihari::Services::RuleProxy] rule # @param [Hash, nil] options # @param [Hash] **_params # def initialize(artifacts:, rule:, options: nil, **_params) super(options: options) @artifacts = artifacts @rule = rule end # @return [Boolean] def valid? raise NotImplementedError, "You must implement #{self.class}##{__method__}" end def result Try[StandardError] do retry_on_error( times: retry_times, interval: retry_interval, exponential_backoff: retry_exponential_backoff ) do emit end end.to_result end def emit raise NotImplementedError, "You must implement #{self.class}##{__method__}" end class << self def inherited(child) super Mihari.emitters << child end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.6.1 | lib/mihari/emitters/base.rb |
mihari-5.6.0 | lib/mihari/emitters/base.rb |