Module: PgNotifier
- Defined in:
- lib/pg_notifier.rb,
lib/pg_notifier/errors.rb,
lib/pg_notifier/manager.rb,
lib/pg_notifier/version.rb,
lib/pg_notifier/subscription.rb
Defined Under Namespace
Classes: ChannelNotLaunched, Manager, PgNotifierError, Subscription
Constant Summary
collapse
- VERSION =
"0.1.3"
Class Method Summary
collapse
Class Method Details
35
36
37
|
# File 'lib/pg_notifier.rb', line 35
def configure(&block)
manager.tap(&block)
end
|
.manager ⇒ Object
8
9
10
|
# File 'lib/pg_notifier.rb', line 8
def manager
@manager ||= Manager.new
end
|
.notify(channel, options = {}, &block) ⇒ Object
31
32
33
|
# File 'lib/pg_notifier.rb', line 31
def notify(channel, options = {}, &block)
manager.notify(channel, options, &block)
end
|
.run ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/pg_notifier.rb', line 12
def run
sig_read, sig_write = IO.pipe
(%w[INT TERM HUP] & Signal.list.keys).each do |sig|
trap sig do
sig_write.puts(sig)
end
end
manager.run
while io = IO.select([sig_read])
sig = io.first[0].gets.chomp
manager.logger.debug "Got #{sig} signal"
manager.shutdown if %w[INT TERM HUP].include? sig
end
end
|