Class: ActiveRecordStreams::Publishers::SnsStream
- Inherits:
-
Object
- Object
- ActiveRecordStreams::Publishers::SnsStream
- Defined in:
- lib/active_record_streams/publishers/sns_stream.rb
Constant Summary collapse
- ANY_TABLE =
'*'
Instance Method Summary collapse
-
#initialize(topic_arn:, table_name: ANY_TABLE, ignored_tables: [], overrides: {}, error_handler: nil) ⇒ SnsStream
constructor
A new instance of SnsStream.
- #publish(table_name, message) ⇒ Object
Constructor Details
#initialize(topic_arn:, table_name: ANY_TABLE, ignored_tables: [], overrides: {}, error_handler: nil) ⇒ SnsStream
Returns a new instance of SnsStream.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_record_streams/publishers/sns_stream.rb', line 15 def initialize( topic_arn:, table_name: ANY_TABLE, ignored_tables: [], overrides: {}, error_handler: nil ) @topic_arn = topic_arn @table_name = table_name @ignored_tables = ignored_tables @overrides = overrides @error_handler = error_handler end |
Instance Method Details
#publish(table_name, message) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_record_streams/publishers/sns_stream.rb', line 33 def publish(table_name, ) return unless (any_table? && allowed_table?(table_name)) || table_name == @table_name client.publish(@topic_arn, .json, @overrides) rescue StandardError => e raise e unless @error_handler.is_a?(Proc) @error_handler.call(self, table_name, , e) end |