Custom Cloudant Replication

Emulating filtered replication using the changes feed and OpenWhisk functions

Glynn Bird
Aug 22, 2017 · 5 min read

One-way street

{
"_id": "3007166d-3fd3-4e3f-be0d-43aa9c054a48", // auto-generated id
"_rev": "1-16e262673ed141f0b711f33e6bb0fdc1", // revision token
"route": "X1",
"name": "Newcastle to London Express",
"start": "Newcastle-upon-Tyne",
"end": "Victoria, London",
"scheduled_start": "2017-08-04 13:05:00 Z",
"actual_start": "2017-08-04 13:08:00 Z",
"scheduled_arrival": "2017-08-04 13:05:00 Z",
"estimated_arrival": "2017-08-04 13:08:00 Z",
"actual_arrival": null,
"stops": [
{
"type": "comfort_break",
"location": "Woodall services",
"start": "2017-08-04 15:00:00 Z",
"actual_start": null,
"end": "2017-08-04 15:30:00 Z",
"actual_end": null
}
],
"driver": {
"name": "Sheila Davies",
"employee_num": "SD_1552"
},
"vehicle": {
"model": "Volvo 9700",
"registration": "PQ89MGW"
}
}
Image courtesy of Flickr user Carlbob.com.

Moving the data

Using CouchDB-style replication to move data to our display boards is good, but it moves all data on all bus trips.
Adding filter functions to CouchDB is a good next step, but performance suffers on large data sets.
Giving each bus station its own database allows replication to be appropriately scoped to each video board.

Custom Cloudant replication with OpenWhisk

Using a serverless function simplifies the amount of replication jobs we’d have to configure in the previous scenario.

Building your own

IBM CODAIT

Things we made with data at IBM’s Center for Open Source Data and AI Technologies.

Thanks to Mike Broberg and Teri Chadbourne.

Glynn Bird

Written by

Developer @ IBM. https://glynnbird.com

IBM CODAIT

Things we made with data at IBM’s Center for Open Source Data and AI Technologies.