Search code examples
c#couchbasecouchbase-litecouchbase-sync-gateway

Get Sync Gateway heartbeat


I have few clients each with installed Couchbase Lite and Sync Gateway and every client's database is replicated to a different bucket on a server.

I know that from the client I can check the heartbeat of the sync using:

curl -X GET 'localhost:4984/db/_changes?feed=continuous&heartbeat=26000&since=0'

How do I do that from the server? What is the proper way of doing so?

Basically, I need to know if one of the Sync Gateway instances is offline and which without knowing their IPs.

On the server, I have a service(REST API) and in the Sync Gateway JSON config I have an event handler that sends updates to it:

“event_handlers”: {
    “document_changed”: [
        {
            “handler”: “webhook”,
            “url”: “http://serverip:port/events/newupdate?=clientId”
        }
    ]
}

Can I somehow add a custom event for the heartbeat?


Solution

  • You can create a background process, that posts the updates to a document, containing the heartbeat, and then replicate that document with the Sync Gateway.