Sha256: 6e0f9b19b3893aab1bc44ab86888b91fb703c494469ff2bafacfbbd594d9d6d9

Contents?: true

Size: 592 Bytes

Versions: 6

Compression:

Stored size: 592 Bytes

Contents

module Pheme
  class TopicPublisher
    attr_accessor :topic_arn

    def initialize(topic_arn:)
      raise ArgumentError, "must specify non-nil topic_arn" unless topic_arn.present?
      @topic_arn = topic_arn
    end

    def publish_events
      raise NotImplementedError
    end

    def publish(message)
      Pheme.log(:info, "Publishing to #{topic_arn}: #{message}")
      Pheme.configuration.sns_client.publish(topic_arn: topic_arn, message: serialize(message))
    end

    def serialize(message)
      return message if message.is_a? String
      message.to_json
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pheme-0.0.10 lib/pheme/topic_publisher.rb
pheme-0.0.9 lib/pheme/topic_publisher.rb
pheme-0.0.8 lib/pheme/topic_publisher.rb
pheme-0.0.7 lib/pheme/topic_publisher.rb
pheme-0.0.6 lib/pheme/topic_publisher.rb
pheme-0.0.5 lib/pheme/topic_publisher.rb