Object Monitor - Using PGQ for something besides Londiste!

Talk Type: 
45 Minute Talk
Track: 
Application development
Technical Level: 
Intermediate
License: 
BSD

Object Monitor - Using PGQ for something besides Londiste!

Object Monitor is a set of wrapper functions around PGQ that we developed at Enova Financial that allow you to work with collections of PGQ queues so that you can monitor application objects and periodically get a list of all those objects that have changed since the last time you asked. Because it is built around PGQ, it is transaction safe and concurrency friendly.

Object Monitor was conceived because an application object is often made up of more than one table. For instance, a "customer" might be made up of the following tables: person, customer, address, phone_number, etc., and using Object Monitor, you can manipulate all the PGQ queues involved with a single call to a Postgres function. Additionally, at times you're only concerned with which things have changed since last time you looked, rather than what those specific changes were.

We will discuss the general concept and design, as well as the two specific use cases we have for this at Enova. Following that we will cover the API as it exists now, and the normal usage patterns, such as:

* Creating a monitor
* Adding tables to and removing tables from an existing monitor
* Subscribing to and unsubscribing from a monitor
* Draining a queue
* Building views around it that marshal up the changed objects

Source code will be provided.