Class: Circuitry::Subscriber
- Inherits:
-
Object
- Object
- Circuitry::Subscriber
- Includes:
- Concerns::Async, Circuitry::Services::SQS
- Defined in:
- lib/circuitry/testing.rb,
lib/circuitry/subscriber.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ lock: true, async: false, timeout: 15, wait_time: 10, batch_size: 10 }.freeze
- CONNECTION_ERRORS =
[ Aws::SQS::Errors::ServiceError ].freeze
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#wait_time ⇒ Object
readonly
Returns the value of attribute wait_time.
Attributes included from Concerns::Async
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Subscriber
constructor
A new instance of Subscriber.
- #subscribe(&block) ⇒ Object
- #subscribed? ⇒ Boolean
Methods included from Circuitry::Services::SQS
Methods included from Concerns::Async
#async?, included, #process_asynchronously
Constructor Details
#initialize(options = {}) ⇒ Subscriber
Returns a new instance of Subscriber.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/circuitry/subscriber.rb', line 29 def initialize( = {}) = DEFAULT_OPTIONS.merge() self.subscribed = false self.queue = Queue.find(Circuitry.subscriber_config.queue_name).url %i[lock async timeout wait_time batch_size].each do |sym| send(:"#{sym}=", [sym]) end trap_signals end |
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
15 16 17 |
# File 'lib/circuitry/subscriber.rb', line 15 def batch_size @batch_size end |
#lock ⇒ Object
Returns the value of attribute lock.
15 16 17 |
# File 'lib/circuitry/subscriber.rb', line 15 def lock @lock end |
#queue ⇒ Object
Returns the value of attribute queue.
15 16 17 |
# File 'lib/circuitry/subscriber.rb', line 15 def queue @queue end |
#timeout ⇒ Object
Returns the value of attribute timeout.
15 16 17 |
# File 'lib/circuitry/subscriber.rb', line 15 def timeout @timeout end |
#wait_time ⇒ Object
Returns the value of attribute wait_time.
15 16 17 |
# File 'lib/circuitry/subscriber.rb', line 15 def wait_time @wait_time end |
Class Method Details
.async_strategies ⇒ Object
62 63 64 |
# File 'lib/circuitry/subscriber.rb', line 62 def self.async_strategies super - [:batch] end |
.default_async_strategy ⇒ Object
66 67 68 |
# File 'lib/circuitry/subscriber.rb', line 66 def self.default_async_strategy Circuitry.subscriber_config.async_strategy end |
Instance Method Details
#subscribe(&block) ⇒ Object
11 12 13 |
# File 'lib/circuitry/testing.rb', line 11 def subscribe(&_block) # noop end |
#subscribed? ⇒ Boolean
58 59 60 |
# File 'lib/circuitry/subscriber.rb', line 58 def subscribed? subscribed end |