Sha256: ddb4524f1bd01aef709b4a6ac561198cd66e799d04ec3501c12a5864cacb692f

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Maitredee
  module Adapters
    class TestAdapter < BaseAdapter
      # logs message published
      def publish(message)
        messages << message
      end

      # returns all messages that have been published since last #reset
      def messages
        @messages ||= []
      end

      # no-op
      def add_worker(subscriber_class)
      end

      # resets messages logged
      def reset
        messages.clear
      end
    end
  end

  class Subscriber
    def self.test(
      body:,
      event_name: nil,
      message_id: SecureRandom.uuid,
      sent_at: Time.now,
      primary_key: nil
    )
      message = SubscriberMessage.new(
        topic_name: topic_name,
        body: body,
        event_name: event_name,
        message_id: message_id,
        sent_at: sent_at.to_i,
        primary_key: primary_key,
        schema_name: nil,
        broker_message_id: message_id,
        maitredee_version: Maitredee::VERSION,
        raw_message: nil,
        adapter_message: nil
      )
      process(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
maitredee-0.8.4 lib/maitredee/adapters/test_adapter.rb