Sha256: 4c811e9759605c8fff09c1bbc85dbe3f81062f5baff6ba7ec6727553f5c46ac8

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

require 'simnos/utils'

module Simnos
  class DSL
    class Subscription
      include Simnos::TemplateHelper

      def create
        Simnos.logger.info("Create Topic(#{@aws_topic[:topic].topic_arn.split(':').last}) Subscription. protocol: #{protocol.inspect}, endpoint: #{endpoint.inspect}#{@options[:dry_run] ? ' [dry-run]' : ''}")
        return if @options[:dry_run]

        client.subscribe(
          topic_arn: @aws_topic[:topic].topic_arn,
          protocol: protocol,
          endpoint: endpoint,
        )
      end

      def aws_topic(aws_topic)
        @aws_topic = aws_topic
        self
      end

      def initialize(context, topic: , protocol: , endpoint: )
        @context = context
        @options = @context.options
        @topic = topic
        @protocol = protocol
        @endpoint = endpoint
      end

      attr_reader :topic, :protocol, :endpoint

      private

      def client
        @client ||= Simnos::ClientWrapper.new(@context)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simnos-0.1.1.beta1 lib/simnos/dsl/subscription.rb
simnos-0.1.0 lib/simnos/dsl/subscription.rb