Module: RailsPipeline::SnsPublisher::InstanceMethods
- Defined in:
- lib/rails-pipeline/sns_publisher.rb
Instance Method Summary collapse
- #_account_id ⇒ Object
- #_sns ⇒ Object
-
#_subject ⇒ Object
Subject of SNS message is ClassName-id.
- #_topic_arn(topic_name, region = "us-east-1") ⇒ Object
- #publish(topic_name, data) ⇒ Object
Instance Method Details
#_account_id ⇒ Object
51 52 53 54 55 56 |
# File 'lib/rails-pipeline/sns_publisher.rb', line 51 def _account_id if ENV.has_key?("AWS_ACCOUNT_ID") return ENV["AWS_ACCOUNT_ID"] end return RailsPipeline::SnsPublisher.account_id end |
#_sns ⇒ Object
37 38 39 40 |
# File 'lib/rails-pipeline/sns_publisher.rb', line 37 def _sns @sns = AWS::SNS.new if @sns.nil? return @sns end |
#_subject ⇒ Object
Subject of SNS message is ClassName-id
47 48 49 |
# File 'lib/rails-pipeline/sns_publisher.rb', line 47 def _subject "#{self.class.name}-#{self.id}" end |
#_topic_arn(topic_name, region = "us-east-1") ⇒ Object
42 43 44 |
# File 'lib/rails-pipeline/sns_publisher.rb', line 42 def _topic_arn(topic_name, region="us-east-1") "arn:aws:sns:#{region}:#{_account_id}:#{topic_name}" end |
#publish(topic_name, data) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rails-pipeline/sns_publisher.rb', line 29 def publish(topic_name, data) t0 = Time.now topic = _sns.topics[_topic_arn(topic_name)] topic.publish(data, subject: _subject, sqs: data) t1 = Time.now RailsPipeline.logger.debug "Published to SNS '#{topic_name}' in #{t1-t0}s" end |