All Projects → emilbayes → pg-ipc

emilbayes / pg-ipc

Licence: other
IPC over PostgreSQL LISTEN/NOTIFY/UNLISTEN exposed as an EventEmitter

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pg-ipc

pg-pubsub
Reliable PostgreSQL LISTEN/NOTIFY with inter-process lock support
Stars: ✭ 50 (+85.19%)
Mutual labels:  postgres, pubsub
Iceoryx
iceoryx - true zero-copy inter-process-communication
Stars: ✭ 208 (+670.37%)
Mutual labels:  ipc, pubsub
Node Pg Pubsub
A Publish/Subscribe implementation on top of PostgreSQL NOTIFY/LISTEN
Stars: ✭ 194 (+618.52%)
Mutual labels:  postgres, pubsub
google-cloud
A collection of Google Cloud Platform (GCP) plugins
Stars: ✭ 34 (+25.93%)
Mutual labels:  pubsub
clunk
Clojure Postgres w/out JDBC
Stars: ✭ 25 (-7.41%)
Mutual labels:  postgres
rocket-rest-api-with-jwt
A Rusty Rocket fuelled with Diesel and secured by JWT
Stars: ✭ 62 (+129.63%)
Mutual labels:  postgres
django-postgres-copy
Quickly import and export delimited data with Django support for PostgreSQL's COPY command
Stars: ✭ 151 (+459.26%)
Mutual labels:  postgres
pg-search-sequelize
Postgres full-text search in Node.js and Sequelize.
Stars: ✭ 31 (+14.81%)
Mutual labels:  postgres
socket
Dazzle Async Socket
Stars: ✭ 19 (-29.63%)
Mutual labels:  ipc
Odin-Securities
A master database of securities data for use with the Odin algorithmic trading platform.
Stars: ✭ 17 (-37.04%)
Mutual labels:  postgres
migrant lib
Embeddable migration management
Stars: ✭ 22 (-18.52%)
Mutual labels:  postgres
pgxmock
pgx mock driver for golang to test database interactions
Stars: ✭ 97 (+259.26%)
Mutual labels:  postgres
ipfs-chat
Real-time P2P messenger using go-ipfs pubsub. TUI. End-to-end encrypted texting & file-sharing. NAT traversal.
Stars: ✭ 84 (+211.11%)
Mutual labels:  pubsub
flan
A tasty tool that lets you save, load and share postgres snapshots with ease
Stars: ✭ 177 (+555.56%)
Mutual labels:  postgres
pg global temp tables
Oracle-style global temporary tables for PostgreSQL
Stars: ✭ 16 (-40.74%)
Mutual labels:  postgres
ash postgres
A postgresql datalayer for the Ash Framework
Stars: ✭ 21 (-22.22%)
Mutual labels:  postgres
postgresql lwrp
Express 42 postgresql cookbook
Stars: ✭ 57 (+111.11%)
Mutual labels:  postgres
phpPgAdmin6
PHP7+ Based administration tool for PostgreSQL 9.3+
Stars: ✭ 45 (+66.67%)
Mutual labels:  postgres
pgsink
Logically replicate data out of Postgres into sinks (files, Google BigQuery, etc)
Stars: ✭ 53 (+96.3%)
Mutual labels:  postgres
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (+0%)
Mutual labels:  postgres

pg-ipc

IPC over PostgreSQL LISTEN/NOTIFY/UNLISTEN exposed as an EventEmitter

Usage

var pgIPC = require('pg-ipc')
var client = new require('pg').Client({ ... })

var ipc = pgIPC(client)

ipc.on('error', console.error)

ipc.on('end', function () {
  client.end()
})

ipc.on('someChannel', function (msg) {
  // Ignore messages from this process
  if (msg.processId === client.processID) return
  console.log(msg.payload.currentTime)
})

ipc.notify('someChannel', {currentTime: Date.now()})

// some time later ...

ipc.end()

API

pgIPC(client)

Instantiates a new EventEmitter with the appropriate hooks to automatically LISTEN/NOTIFY/UNLISTEN. Note that client must be a pg.Client instance and not a pg.Pool, as a single connection is required.

ipc.on(channel, listener)

All the standard EventEmitter methods are exposed. When a listener is added to channel, a LISTEN command is automatically issued, and UNLISTEN when the number of listeners reach zero. The listener will receive the message as its first argument. Notable properties being channel, payload, processId. Each postgres connection is assigned a unique processId, which can be used to ignore messages from the same process. See EventEmitter for more details. Reserved channels are: ['newListener', 'removeListener', 'notify', 'unlisten', 'listen', 'error', 'end']

ipc.notify(channel[, payload])

Alias: ipc.send(channel[, payload]). Send a message to channel with optional payload. payload is transparently converted to JSON where appropriate.

ipc.end()

Issue UNLISTEN * if connected, emit end and detach all event listeners. Does not call client.end() so you can continue using the client. However, any listeners you've issued outside outside of this module will also be detached

Event: listen

Emitted when a LISTEN has been successfully issued. Passed channel

Event: notify

Emitted after a notification has been successfully sent. Passed channel and payload

Event: unlisten

Emitted when a UNLISTEN has been successfully issued. Passed channel

Event: end

Emitted when all LISTENs have been removed, but before all event listeners are removed.

Event: error

Propagates any errors caused by queries on Client. Passed the err argument from the query callback.

Install

npm install pg-ipc

License

ISC

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].