Just a first cut at the shape of a candidate
The idea being that this would be a ServiceStack
IPlugin with one-line registration
that includes a built-in webhook subscription web service, that consumers can register and manage callbacks to be POSTED events raised by your own service.
We would need to make it highly extensible so ServiceStack developers can control how the main components work in their architectures, and make it a highly testable and easy to stub the various components in testing environments.
How It Works
Your service (internally) uses a
IWebhookPublisher.Publish<T>(string eventName, T event) to publish things that happen in your service (each with a unique
eventName and unique POCO event (containing event data).
The WebhookFeature then publishes your events to a reliable storage mechanism of your choice (i.e. queue, DB, remote cloud service, etc). This is configurable in the
Then depending on your architecture, you can have any number of workers relay those events to subscribers to your events.
Note: not quite resolved the relay end of things yet (ran out of time). For example, in an Azure cloud architecture you might use a WorkerRole to check the queue every second, and then relay to all subscribers. In AWS you might use Lambda to relay to all subscribers. In another architecture, you might do things on a background thread, triggered by the `IWebhookPublisher.Publish(). In any case we need a cross-process way that relays can find out who the subscribers are and easily dispatch to them.
Another thing to thing about is whether to include those things in a separate nuget (specific to a architecture) rather than bundling everything in to the main one. I can see people wanting flexibility in the following things: the kind of storage for subscriptions (MemoryCache/DB by default), the kind of reliable storage of events (MemoryCache/DB by default), and the relay component (in memory, background thread by default).
I guess what I am looking for at this point is if there is anyone with an appetite to co-design/develop this further??, and whether we should create a new repo for it, and get started? @mythz, @layoric?