Class: Bricolage::SNSDataSource
- Inherits:
-
DataSource
- Object
- DataSource
- Bricolage::SNSDataSource
- Defined in:
- lib/bricolage/snsdatasource.rb
Constant Summary
Constants inherited from DataSource
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Attributes inherited from DataSource
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(region:, topic_arn:, access_key_id: nil, secret_access_key: nil) ⇒ SNSDataSource
constructor
A new instance of SNSDataSource.
- #publish(message) ⇒ Object (also: #write)
Methods inherited from DataSource
get_class, new_for_type, #open, #open_for_batch, #redshift_loader_source?
Constructor Details
#initialize(region:, topic_arn:, access_key_id: nil, secret_access_key: nil) ⇒ SNSDataSource
Returns a new instance of SNSDataSource.
10 11 12 13 14 15 16 17 |
# File 'lib/bricolage/snsdatasource.rb', line 10 def initialize(region:, topic_arn:, access_key_id: nil, secret_access_key: nil) @region = region @topic_arn = topic_arn @access_key_id = access_key_id @secret_access_key = secret_access_key @client = Aws::SNS::Client.new(region: region, access_key_id: access_key_id, secret_access_key: secret_access_key) @topic = Aws::SNS::Topic.new(topic_arn, client: @client) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
20 21 22 |
# File 'lib/bricolage/snsdatasource.rb', line 20 def client @client end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
19 20 21 |
# File 'lib/bricolage/snsdatasource.rb', line 19 def region @region end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
21 22 23 |
# File 'lib/bricolage/snsdatasource.rb', line 21 def topic @topic end |
Instance Method Details
#close ⇒ Object
35 36 |
# File 'lib/bricolage/snsdatasource.rb', line 35 def close end |
#publish(message) ⇒ Object Also known as: write
23 24 25 26 27 28 29 |
# File 'lib/bricolage/snsdatasource.rb', line 23 def publish() @topic.publish({ message: }) rescue Aws::SNS::Errors::InvalidParameter => ex raise JobError, "bad SNS configuration (topic_arn=#{@topic_arn.inspect}): #{ex.}" rescue Aws::SNS::Errors::ServiceError => ex raise SNSException.wrap(ex) end |