Plugins

Jezz Santos edited this page Mar 11, 2017 · 21 revisions

When we say "plugins", we are referring to the plugins IEventSink and ISubscriptionStore components you will want to have in your webhook implementation to complete it.

You will have to select and register at least one of each of these things for your webhooks to work end-to-end.

We are expecting everyone who uses the 'ServiceStack.Webhooks' framework to have different requirements for deploying their webhooks, and so everyone will require a variety of plugins to choose from.

Provided Plugins

This project, ServiceStack.Webhooks provides a few plugins that can be used right away without installing any other nuget packages. They are:

AppHostEventSink

The built-in and default IEventSink that delivers events to subscribers in-proc with the service that raised the event. Great for testing, crappy for production.

WARNING: If you don't register any other IEventSink this one is used as the default.

WARNING: About the built-in AppHostEventSink is extremely limited in what it does. It runs in-proc with your service request pipeline and attempts to raise events to all subscribers on the same thread as the thread that raises the event from your service! That means that your service API call is going to sit there while events are delivered to every subscriber (across the network). This is great for functional testing, but rubbish in production environments. You absolutely need to swap it out for something that is far more scalable, reliable and performant.

MemorySubscriptionStore

The built-in and default ISubscriptionStore that saves subscriptions in the memory of your service. Great for testing, crappy for production.

WARNING: If you don't register any other ISubscriptionStore this one is used as the default.

WARNING: About the built-in MemorySubscriptionStore is extremely limited in what it does. It stores subscriber subscriptions in the memory of your service, which are all going to be lost whenever your AppHost restarts. Which is kind of rubbish in production environments. You will probably want to use something that has a little more persistence than that like a database or cache of some kind.

CacheClientSubscriptionStore

An ISubscriptionStore that will use the currently registered ICacheClient.

If you already have your own ICacheClient registered in your AppHost and want to use that as your subscription store, you can simply just register the CacheClientSubscriptionStore as your ISubscriptionStore.

So for example, if you want to use Redis as your store, you could just do this:

container.Register<IRedisClientsManager>(c => 
    new PooledRedisClientManager("localhost:6379"));
container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
container.RegisterAutoWiredAs<CacheClientSubscriptionStore, ISubscriptionStore>();

Plugins.Add(new WebhookFeature());

WARNING: About the CacheClientSubscriptionStore is not that optimal as a store using the ICacheClient interface. ICacheClient forces us to use cache keys that enforce a linear index, that is not really optimal for the kinds of varied searches that ISubscriptionStore demands. If you really want to create a more more optimal ISubscriptionStore for your database/backend, you are better not to use the CacheClientSubscriptionStore and write your own dedicated ISubscriptionStore for your data specific store. Then of course share it on github for others to use. We will list it here or you.

Community Provided Plugins

These are the known additional 'Plugins' to the ServiceStack.Webhooks framework:

(last updated of 11th March 2017)

ServiceStack.Webhooks.Azure

This plugin includes an Azure table storage ISubscriptionStore for storing subscriptions, and includes an Azure Queue IEventSink and an Azure WorkerRole for delivering events to subscribers.

See Getting Started for more details.

ServiceStack.Webhooks.OrmLite

This plugin provides an ISubscriptionStore for OrmLite enabling the use of any OrmLite connected store.

To make use of OrmLiteSubscriptionStore you first need to install the OrmLite NuGet package of the RDBMS you wish to use then register the Dialect Provider and connection string you wish to use, e.g:

container.Register<IDbConnectionFactory>(c => 
    new OrmLiteConnectionFactory(connectionString, SqlServer2012Dialect.Provider));

Which is used to register the OrmLiteSubscriptionStore:

container.Register<ISubscriptionStore>(c => 
    new OrmLiteSubscriptionStore(c.Resolve<IDbConnectionFactory>()));

//Create WebhookSubscription and SubscriptionDeliveryResult tables if they don't exist
container.Resolve<ISubscriptionStore>().InitSchema();

Build Your Own Plugin

If you don't see what you are looking for here, see the Building Your Own Plugin page for how to get what you need.

(Just don't forget to tell us here about it, so we can add it to this list).

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.