-
Notifications
You must be signed in to change notification settings - Fork 7
Home
In general, Webhooks are a common asynchronous means today for listening to key 'events' raised by online systems, typically over HTTPS. The idea is simple, register a callback URL to call when an event is raised, and the system will POST you something to that URL when the event is raised. You register the callback URL with the system, and you typically select the event type (which implies a specific DTO of the event). And then you sit back and wait to be called.
Webhooks are a good example of pub/sub architectures, where the consumers of the events are decoupled from the producer of the events.
In this project, we are basing the subscription model of webhooks on that defined by GitHub Webhooks.
In this project, we are going to provide an API that stores subscriptions in a built-in 'Webhooks' service that will be hosted your service (the one that registers the WebhookFeature
plugin. This service will allow users of your service to create, list, update and delete subscriptions to events that your services raises.
In this project, the IWebhookPublisher
singleton, will publish an event (IWebhookPublisher.Publish<TDto>(string event, TDto data)
) to a central store (i.e. DB, queue, etc), and a IWebhookRelay.NotifySubscribers()
will relay the stored event to all registered subscribers at that time.
The publisher and the relay are likely to be (depending on how you configure the WebhookFeature
decoupled from each other, and in some cases run in different networks/clouds etc.
There are several points of extensibility in this implementation:
- How and where to store subscriptions (i.e DB, Memory, etc) in the configured
IWebhookSubscriptionStore
Component - How and where to store published events (i.e. DB, queue, cloud function) in the configured
IWebhookEventStore
Component - How to relay events to subscribers (i.e. In a Cloud function, in-process function, worker role, scheduled process etc.) in the configured
IWebhookRelay
Component
In this project, there can be (depending on the community contribution) several nuget packages that need to deliver each of these components depending on the architecture of your service.
- The nuget package 'Servicestack.Webhooks' will provide the
WebhookFeature
and subscription service, andIWebhook
implementation. It may also provide an in-processInProcWebhookRelay
for relaying events from the service that raised them (stored in Memory/DB). - The nuget package 'Servicestack.Webhooks.Interfaces' (included in all other packages) will provide all the definitions of all the services and key DTO's involved in all layers of the architecture.
- The nuget package 'Servicestack.Webhooks.Azure' (for example) would provide
IWebhookEventStore
as an Azure queue, and aQueueWebhookRelay
For relaying queued events to subscribers