Class: RisingDragon::SNS::Publisher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sns_client) ⇒ Publisher

Returns a new instance of Publisher.



5
6
7
8
9
# File 'lib/rising_dragon/sns/publisher.rb', line 5

def initialize(sns_client)
  @sns_client = sns_client
  @topic_cache = {}
  @use_cache = true # default true :)
end

Instance Attribute Details

#use_cacheObject

Returns the value of attribute use_cache.



4
5
6
# File 'lib/rising_dragon/sns/publisher.rb', line 4

def use_cache
  @use_cache
end

Instance Method Details

#publish(topic_name, event_type, data) ⇒ Object



11
12
13
14
15
16
# File 'lib/rising_dragon/sns/publisher.rb', line 11

def publish(topic_name, event_type, data)
  event = create_event(event_type, data)

  topic = get_topic(topic_name)
  @sns_client.publish(topic_arn: topic.topic_arn, message: event.to_json)
end