[abacus] Handling Notifications

Benjamin Cheng

I've begun to work on supporting notifications in abacus. We already have a github issue and pivotal tracker story associated with it as seen here:
Abacus needs to have some support of sending a notification to some client based upon some criteria being met.

Right now, I'm in an exploratory phase. There are two ways that this will probably need to work. One via a webhook and another via letting a client keep and open connection that would receive a stream of notifications. Here's a very basic breakdown.

In terms of the webhook, there's two things to consider:
-Maintaining the information of the clients and their criteria
-Calling the provided callback URLs when a certain criteria is met

For the registry, I have considered Eureka(specifically, the module inside of abacus) since the registration spec has a metadataType property that hold a sequence of anything. Eureka is used as a registry for middle tier services(or application instances in our case), so I'm not sure if also using it as a registry for handling notifications would kind of warp the purpose of its use. There's also some other things such as the heartbeats that I'm not sure would be the right fit in terms of a webhook.
Maintaining the list of the URLs in a database with a separate "Notification Registry/Hander" app could work as well. Documents would probably be keyed to the given URL just for supporting updates on new criteria for a certain callback URL and prevent multiple documents for the same URL. Each document would hold a list of criteria if that's the case.

When some usage gets rated, that usage would be checked against the list of URLs. All the matching URLs would be called in parallel. If a call is successful, then there's nothing additional that needs to be done. If a call is an error, it'd be best to retry for a set amount of time/tries until that particular URL is marked unreachable(and thus isn't called in subsequent notifications).

I haven't begun on the other avenue of keeping an open connection but wanted to start a discussion with just the webhook for now.

Any thoughts, comments, or suggestions on this?

Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.