Skip to content

PullingHook turns any pull into a push, extensible and on a schedule

License

Notifications You must be signed in to change notification settings

lvermeulen/PullingHook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon

PullingHook

Build status license NuGet Coverage Status codecov Join the chat at https://gitter.im/lvermeulen/pullinghook

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.

Features:

  • Fluent builder
  • Extensible storage
  • Extensible scheduling

Samples:

  • 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

Usage:

  • 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();
}

Thanks

About

PullingHook turns any pull into a push, extensible and on a schedule

Resources

License

Stars

Watchers

Forks

Packages

No packages published