An open API service indexing awesome lists of open source software.

https://github.com/mr-dxdy/pg_notifier

Process notifies about notifications from postgresql
https://github.com/mr-dxdy/pg_notifier

pg ruby

Last synced: about 1 year ago
JSON representation

Process notifies about notifications from postgresql

Awesome Lists containing this project

README

          

# PgNotifier

Process notifies about postgresql notifications.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'pg_notifier'
```

## Quickstart

Create notifiers.rb:

``` ruby
require 'pg_notifier'

module PgNotifier
configure do |notifier|
notifier.logger = Logger.new('/var/log/pg_notifier.log')
notifier.db_config = {
host: 'localhost',
port: 5432,
dbname: database_production,
user: 'postgres',
password: 'postgres'
}
end

notify 'created_user' do |channel, pid, payload|
puts "#{channel} #{pid} #{payload}"
end
end
```
Run it with the pg_notifier executable:

``` bash
$ pg_notifier notifiers.rb
```

If you need to load your entire environment for your jobs, simply add:

``` bash
require 'pg_notifier'

require './config/boot'
require './config/environment'
```