Class: Eventboss::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/eventboss/publisher.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_name, sns_client, configuration, opts = {}) ⇒ Publisher

Returns a new instance of Publisher.



5
6
7
8
9
10
# File 'lib/eventboss/publisher.rb', line 5

def initialize(event_name, sns_client, configuration, opts = {})
  @event_name = event_name
  @sns_client = sns_client
  @configuration = configuration
  @source = configuration.eventboss_app_name unless opts[:generic]
end

Instance Method Details

#publish(payload) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/eventboss/publisher.rb', line 12

def publish(payload)
  topic_arn = Topic.build_arn(event_name: event_name, source_app: source)
  sns_client.publish(
    topic_arn: topic_arn,
    message: json_payload(payload)
  )
end