Sha256: 80b0b93f52e910a621ad2af32aadc02916db81857ff86311c3c87075ba72d016

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 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

      include HermesMessengerOfTheGods::Concerns::Message

      class_methods do
        def endpoints=(*args)
          super
          worker_klass.endpoints = endpoints
        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.endpoints = me.endpoints
            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

13 entries across 13 versions & 1 rubygems

Version Path
hermes_messenger_of_the_gods-2.4.2 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.4.1 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.4.0.pre2 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.4.0.pre1 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.3.4 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.3.3 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.3.2 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.3.1 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.3.0 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.2.0 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.1.1 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.1.0 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb
hermes_messenger_of_the_gods-2.0.0 lib/hermes_messenger_of_the_gods/concerns/mono_message.rb