Module: Downstream
- Defined in:
- lib/downstream.rb,
lib/downstream/event.rb,
lib/downstream/config.rb,
lib/downstream/engine.rb,
lib/downstream/version.rb,
lib/downstream/rspec/have_published_event.rb,
lib/downstream/pubsub_adapters/abstract_pubsub.rb,
lib/downstream/pubsub_adapters/stateless/pubsub.rb,
lib/downstream/pubsub_adapters/stateless/subscriber.rb
Defined Under Namespace
Modules: Stateless
Classes: AbstractPubsub, Config, Engine, Event, HavePublishedEvent
Constant Summary
collapse
- VERSION =
"1.1.0"
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
15
16
17
|
# File 'lib/downstream.rb', line 15
def config
@config ||= Config.new
end
|
19
20
21
|
# File 'lib/downstream.rb', line 19
def configure
yield config
end
|
.publish(event) ⇒ Object
41
42
43
|
# File 'lib/downstream.rb', line 41
def publish(event)
pubsub.publish("#{config.namespace}.#{event.type}", event)
end
|
.subscribe(subscriber = nil, to: nil, &block) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/downstream.rb', line 23
def subscribe(subscriber = nil, to: nil, &block)
subscriber ||= block if block
raise ArgumentError, "Subsriber must be present" if subscriber.nil?
identifier = construct_identifier(subscriber, to)
pubsub.subscribe(identifier, subscriber)
end
|
.subscribed(subscriber, to: nil, &block) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/downstream.rb', line 33
def subscribed(subscriber, to: nil, &block)
raise ArgumentError, "Subsriber must be present" if subscriber.nil?
identifier = construct_identifier(subscriber, to)
pubsub.subscribed(identifier, subscriber, &block)
end
|