Sha256: 2ce8fead47dd7b06af73f2cdc929e2f5221e85a3009cbe4d57ff24821df1f0ff

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'active_support'

require 'hermes_messenger_of_the_gods/concerns/message'
require 'hermes_messenger_of_the_gods/concerns/worker'

module HermesMessengerOfTheGods
  module Concerns
    module MonoMessage
      extend ActiveSupport::Concern

      def self.included(other)
        other.include HermesMessengerOfTheGods::Concerns::Message
      end

      class_methods do
        def endpoint=(*args)
          super
          worker_klass.endpoint = endpoint
        end

        def circuit_breaker_errors=(*args)
          super
          worker_klass.circuit_breaker_errors = circuit_breaker_errors
        end

        def max_consecutive_failures=(*args)
          super
          worker_klass.max_consecutive_failures = max_consecutive_failures
        end

        def build_worker
          worker_klass.build_worker
        end

        def work_off
          build_worker.work_off
        end

        def worker_klass
          me = self
          @worker_klass ||= Class.new do
            include HermesMessengerOfTheGods::Concerns::Worker
            self.endpoint = me.endpoint
            self.circuit_breaker_errors = me.circuit_breaker_errors
            self.max_consecutive_failures = me.max_consecutive_failures
            self.deserialize_with = me
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hermes_messenger_of_the_gods-3.0.0 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-3.0.0.rc5 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-3.0.0.rc4 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-3.0.0.rc3 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-3.0.0.rc2 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-3.0.0.rc1 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb