Module: Propono
- Defined in:
- lib/propono.rb,
lib/propono/utils.rb,
lib/propono/logger.rb,
lib/propono/version.rb,
lib/propono/configuration.rb,
lib/propono/propono_error.rb,
lib/propono/components/sns.rb,
lib/propono/components/sqs.rb,
lib/propono/components/queue.rb,
lib/propono/components/topic.rb,
lib/propono/services/publisher.rb,
lib/propono/services/subscriber.rb,
lib/propono/components/aws_config.rb,
lib/propono/services/tcp_listener.rb,
lib/propono/services/udp_listener.rb,
lib/propono/components/sqs_message.rb,
lib/propono/services/queue_creator.rb,
lib/propono/services/topic_creator.rb,
lib/propono/services/queue_listener.rb,
lib/propono/components/post_subscription.rb,
lib/propono/components/queue_subscription.rb
Overview
Propono is a pub/sub gem built on top of Amazon Web Services (AWS). It uses Simple Notification Service (SNS) and Simple Queue Service (SQS) to seamlessly pass messages throughout your infrastructure.
Defined Under Namespace
Modules: Sns, Sqs, Subscriber, Utils Classes: AwsConfig, Configuration, Logger, PostSubscription, ProponoConfigurationError, ProponoError, Publisher, PublisherError, Queue, QueueCreator, QueueCreatorError, QueueListener, QueueSubscription, SqsMessage, TcpListener, TcpListenerError, Topic, TopicCreator, TopicCreatorError, UdpListener, UdpListenerError
Constant Summary collapse
- VERSION =
"1.6.0"
Class Method Summary collapse
- .aws_options ⇒ Object
-
.config ⇒ Object
Propono configuration settings.
-
.drain_queue(topic, &message_processor) ⇒ Object
Listens on a queue and yields for each message.
-
.listen_to_queue(topic, &message_processor) ⇒ Object
Listens on a queue and yields for each message.
-
.listen_to_tcp(&message_processor) ⇒ Object
Listens for TCP messages and yields for each.
-
.listen_to_udp(&message_processor) ⇒ Object
Listens for UDP messages and yields for each.
-
.proxy_tcp ⇒ Object
Listens for TCP messages and passes them onto the queue.
-
.proxy_udp ⇒ Object
Listens for UDP messages and passes them onto the queue.
-
.publish(topic, message, options = {}) ⇒ Object
Publishes a new message into the Propono pub/sub network.
-
.subscribe_by_post(topic, endpoint) ⇒ Object
Creates a new SNS-POST subscription on the specified topic.
-
.subscribe_by_queue(topic) ⇒ Object
Creates a new SNS-SQS subscription on the specified topic.
Class Method Details
.aws_options ⇒ Object
3 4 5 |
# File 'lib/propono/components/aws_config.rb', line 3 def self. AwsConfig.new(Propono.config). end |
.config ⇒ Object
Propono configuration settings.
Settings should be set in an initializer or using some other method that insures they are set before any Propono code is used. They can be set as followed:
Propono.config.access_key = "my-access-key"
The following settings are allowed:
-
:access_key
- The AWS access key -
:secret_key
- The AWS secret key -
:queue_region
- The AWS region -
:application_name
- The name of the application Propono is included in. -
:queue_suffix
- Optional string to append to topic and queue names. -
:udp_host
- If using UDP, the host to send to. -
:udp_port
- If using UDP, the port to send to. -
:logger
- A logger object that responds to puts.
51 52 53 54 55 56 57 58 |
# File 'lib/propono.rb', line 51 def self.config @config ||= Configuration.new if block_given? yield @config else @config end end |
.drain_queue(topic, &message_processor) ⇒ Object
Listens on a queue and yields for each message
Calling this will enter a queue-listening loop that yields the message_processor for each messages. The loop will end when all messages have been processed.
This method will automatically create a subscription if one does not exist, so there is no need to call subscribe_by_queue
in addition.
122 123 124 |
# File 'lib/propono.rb', line 122 def self.drain_queue(topic, &) QueueListener.drain(topic, &) end |
.listen_to_queue(topic, &message_processor) ⇒ Object
Listens on a queue and yields for each message
Calling this will enter a queue-listening loop that yields the message_processor for each messages.
This method will automatically create a subscription if one does not exist, so there is no need to call subscribe_by_queue
in addition.
106 107 108 |
# File 'lib/propono.rb', line 106 def self.listen_to_queue(topic, &) QueueListener.listen(topic, &) end |
.listen_to_tcp(&message_processor) ⇒ Object
Listens for TCP messages and yields for each.
Calling this will enter a queue-listening loop that yields the message_processor for each UDP message received.
144 145 146 |
# File 'lib/propono.rb', line 144 def self.listen_to_tcp(&) TcpListener.listen(&) end |
.listen_to_udp(&message_processor) ⇒ Object
Listens for UDP messages and yields for each.
Calling this will enter a queue-listening loop that yields the message_processor for each UDP message received.
133 134 135 |
# File 'lib/propono.rb', line 133 def self.listen_to_udp(&) UdpListener.listen(&) end |
.proxy_tcp ⇒ Object
Listens for TCP messages and passes them onto the queue.
This method uses #listen_to_tcp and #publish to proxy messages from TCP onto the queue.
162 163 164 165 166 |
# File 'lib/propono.rb', line 162 def self.proxy_tcp Propono.listen_to_tcp do |topic, , = {}| Propono.publish(topic, , ) end end |
.proxy_udp ⇒ Object
Listens for UDP messages and passes them onto the queue.
This method uses #listen_to_udp and #publish to proxy messages from UDP onto the queue.
152 153 154 155 156 |
# File 'lib/propono.rb', line 152 def self.proxy_udp Propono.listen_to_udp do |topic, , = {}| Propono.publish(topic, , ) end end |
.publish(topic, message, options = {}) ⇒ Object
Publishes a new message into the Propono pub/sub network.
This requires a topic and a message. By default this pushes out AWS SNS. The method optionally takes a :protocol key in options, which can be set to :udp for non-guaranteed but very fast delivery.
71 72 73 74 |
# File 'lib/propono.rb', line 71 def self.publish(topic, , = {}) suffixed_topic = "#{topic}#{Propono.config.queue_suffix}" Publisher.publish(suffixed_topic, , ) end |
.subscribe_by_post(topic, endpoint) ⇒ Object
Creates a new SNS-POST subscription on the specified topic.
The POST currently needs confirming before the subscription can be published to.
91 92 93 |
# File 'lib/propono.rb', line 91 def self.subscribe_by_post(topic, endpoint) Subscriber.subscribe_by_post(topic, endpoint) end |
.subscribe_by_queue(topic) ⇒ Object
Creates a new SNS-SQS subscription on the specified topic.
This is implicitly called by #listen_to_queue.
81 82 83 |
# File 'lib/propono.rb', line 81 def self.subscribe_by_queue(topic) Subscriber.subscribe_by_queue(topic) end |