PullingHook turns any pull into a push, remembering the previous values pulled and pushing only when something has changed. It will pull on a specified interval and automatically push the changes.
- Fluent builder
- Extensible storage
- Extensible scheduling
- NancyWebhookProducer runs PullingHook and sends a webhook for any detected stock change to its subscribers
- NancyWebhookConsumer subscribes to NancyWebhookProducer and receives a webhook for any stock change
- Fluent builder:
var pullingHook = PullingHook<MyType, Guid>
.WithKeyProperty(x => x.Id)
.WithStorage(new MemoryStorage<decimal>(new Sha1Hasher()))
.WithScheduler(new FluentPullingHookScheduler<MyType, Guid>())
.When(TimeSpan.FromSeconds(5), () => new[] { myType1, myType2, myType3 })
.Then((name, description, changes) =>
{
Console.WriteLine($"Source name: {name}");
Console.WriteLine($"Source description: {description}");
Console.WriteLine($"Added: {changes.Inserts.Count()}");
Console.WriteLine($"Changed: {changes.Updates.Count()}");
Console.WriteLine($"Removed: {changes.Deletes.Count()}");
});
var stoppablePullingHook = pullingHook.Start();
stoppablePullingHook.Stop();
- Extensible storage:
Memory-based storage is provided in PullingHook.Storage.Memory. To implement your own storage:
public interface IPullingSourceStorage<T>
{
IEnumerable<HashedPair<T>> Retrieve(string key);
IEnumerable<HashedPair<T>> Store(string key, IEnumerable<T> values);
}
- Extensible scheduling:
Scheduling is provided in PullingHook.Scheduler.Fluent. To implement your own scheduling:
public interface IPullingScheduler<T, TKeyProperty>
{
void Start(IPullingHookManager<T, TKeyProperty> pullingHookManager);
void Stop();
}
- Fishing Hook icon by Rohith M S from The Noun Project