Class: Propono::Publisher
- Inherits:
-
Object
- Object
- Propono::Publisher
- Defined in:
- lib/propono/services/publisher.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#aws_client ⇒ Object
readonly
Returns the value of attribute aws_client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#propono_config ⇒ Object
readonly
Returns the value of attribute propono_config.
-
#topic_name ⇒ Object
readonly
Returns the value of attribute topic_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(aws_client, propono_config, topic_name, message, async: false, id: nil) ⇒ Publisher
constructor
A new instance of Publisher.
- #publish ⇒ Object
Constructor Details
#initialize(aws_client, propono_config, topic_name, message, async: false, id: nil) ⇒ Publisher
Returns a new instance of Publisher.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/propono/services/publisher.rb', line 14 def initialize(aws_client, propono_config, topic_name, , async: false, id: nil) raise PublisherError.new("Topic is nil") if topic_name.nil? raise PublisherError.new("Message is nil") if .nil? @aws_client = aws_client @propono_config = propono_config @topic_name = topic_name @message = @async = async random_id = SecureRandom.hex(3) @id = id ? "#{id}-#{random_id}" : random_id end |
Instance Attribute Details
#async ⇒ Object (readonly)
Returns the value of attribute async.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def async @async end |
#aws_client ⇒ Object (readonly)
Returns the value of attribute aws_client.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def aws_client @aws_client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def id @id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def @message end |
#propono_config ⇒ Object (readonly)
Returns the value of attribute propono_config.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def propono_config @propono_config end |
#topic_name ⇒ Object (readonly)
Returns the value of attribute topic_name.
12 13 14 |
# File 'lib/propono/services/publisher.rb', line 12 def topic_name @topic_name end |
Class Method Details
.publish(*args) ⇒ Object
8 9 10 |
# File 'lib/propono/services/publisher.rb', line 8 def self.publish(*args) new(*args).publish end |
Instance Method Details
#publish ⇒ Object
28 29 30 31 |
# File 'lib/propono/services/publisher.rb', line 28 def publish propono_config.logger.info "Propono [#{id}]: Publishing #{} to #{topic_name}" async ? publish_asyncronously : publish_syncronously end |