Class: DispatchRider::NotificationServices::AwsSns

Inherits:
Base
  • Object
show all
Defined in:
lib/dispatch-rider/notification_services/aws_sns.rb

Instance Attribute Summary

Attributes inherited from Base

#channel_registrar, #notifier

Instance Method Summary collapse

Methods inherited from Base

#channels, #initialize, #publish

Constructor Details

This class inherits a constructor from DispatchRider::NotificationServices::Base

Instance Method Details

#channel(name) ⇒ Object

not really happy with this, but the notification service registrar system is way too rigid to do this cleaner since you only can have one notifier for the whole service, but you need to create a new one for each region



25
26
27
28
29
# File 'lib/dispatch-rider/notification_services/aws_sns.rb', line 25

def channel(name)
  arn = self.fetch(name)
  region = arn.split(':')[3]
  notifier_builder.new(region: region).topics[arn]
end

#channel_registrar_builderObject



15
16
17
# File 'lib/dispatch-rider/notification_services/aws_sns.rb', line 15

def channel_registrar_builder
  Registrars::SnsChannel
end

#notifier_builderObject



9
10
11
12
13
# File 'lib/dispatch-rider/notification_services/aws_sns.rb', line 9

def notifier_builder
  AWS::SNS
rescue NameError
  raise AdapterNotFoundError.new(self.class.name, 'aws-sdk')
end

#publish_to_channel(channel, message:) ⇒ Object



19
20
21
# File 'lib/dispatch-rider/notification_services/aws_sns.rb', line 19

def publish_to_channel(channel, message:)
  with_retries(max_retries: 10, rescue: AWS::Errors::MissingCredentialsError) { super }
end