Module: MicroBunny
- Defined in:
- lib/microbunny.rb,
lib/microbunny/event.rb,
lib/microbunny/record.rb,
lib/microbunny/payload.rb,
lib/microbunny/settings.rb,
lib/microbunny/connection.rb,
lib/microbunny/subscriber.rb,
lib/microbunny/event_lookup.rb,
lib/microbunny/event_trigger.rb,
lib/microbunny/subscriptions.rb
Defined Under Namespace
Classes: Connection, Event, EventLookup, EventTrigger, Payload, Record, Settings, Subscriber, Subscriptions
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.channel ⇒ Object
Returns the value of attribute channel.
22
23
24
|
# File 'lib/microbunny.rb', line 22
def channel
@channel
end
|
.connection ⇒ Object
Returns the value of attribute connection.
22
23
24
|
# File 'lib/microbunny.rb', line 22
def connection
@connection
end
|
.settings ⇒ Object
Returns the value of attribute settings.
22
23
24
|
# File 'lib/microbunny.rb', line 22
def settings
@settings
end
|
Class Method Details
24
25
26
27
|
# File 'lib/microbunny.rb', line 24
def configure
self.settings ||= Settings.new
yield(settings)
end
|
.event(name) ⇒ Object
56
57
58
|
# File 'lib/microbunny.rb', line 56
def event(name)
EventTrigger.new(channel, name)
end
|
.start ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/microbunny.rb', line 29
def start
self.connection = Connection.new(
adapter: RABBIT_MQ_ADAPTER,
host: self.settings.host,
vhost: self.settings.vhost,
username: self.settings.username,
password: self.settings.password
)
self.channel = self.connection.channel
end
|
.stop ⇒ Object
41
42
43
|
# File 'lib/microbunny.rb', line 41
def stop
self.connection.stop
end
|
.subscribe(topics, record_ids = []) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/microbunny.rb', line 45
def subscribe(topics, record_ids = [])
raise_bad_start unless self.channel
records = record_ids.map(&Record.method(:new))
subs = Subscriptions.new(self.channel, topics, records) do |payload|
handle(payload)
end
subs.create
end
|