Skip to content

Instantly share code, notes, and snippets.

@dkam
Created March 25, 2014 03:56
Show Gist options
  • Save dkam/9755012 to your computer and use it in GitHub Desktop.
Save dkam/9755012 to your computer and use it in GitHub Desktop.
Postgresql pub/sub in Ruby
require 'sequel'
DB = Sequel.connect('postgres://user:pass@localhost/db')
DB.listen(:my_channel, loop: true) {|channel, pid, payload| puts "Got payload '#{payload}' on channel '#{channel}'" }
require 'sequel'
DB = Sequel.connect('postgres://user:pass@localhost/db')
DB.notify(:my_channel, payload: {a: 1, test: true} )
@dkam
Copy link
Author

dkam commented Mar 25, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment