Method: MessageBus::Backends::Postgres#subscribe
- Defined in:
- lib/message_bus/backends/postgres.rb
#subscribe(channel, last_id = nil) {|message| ... } ⇒ nil
Subscribe to messages on a particular channel. Each message since the last ID specified will be delivered by yielding to the passed block as soon as it is available. This will block until subscription is terminated.
| 326 327 328 329 330 331 332 333 334 | # File 'lib/message_bus/backends/postgres.rb', line 326 def subscribe(channel, last_id = nil) # trivial implementation for now, # can cut down on connections if we only have one global subscriber raise ArgumentError unless block_given? global_subscribe(last_id) do |m| yield m if m.channel == channel end end |