Kit is a .NET Core toolkit for microservices that is heavily inspired by go-kit. The goal of Kit is to provide a common set of abstractions for platform components of a microservice framework.
The Service Discovery packages provide a set of abstractions for pluggable service discovery into the toolkit.
This project is still in development and subject to change. Please create an issue with any feedback.
- Abstractions - Common abstractions for service discovery
- Cache - A caching discovery provider that can be chained with other discovery providers
- LoadBalancer - Add load balancing algorithms to service discovery providers
- Multi - Add multiple providers and returns the first provider with endpoints
- Throttle - A throttling discovery provider that can be chained with other discovery providers
A full working example can be found in the samples directory.
All requests for endpoints will request directly against the Consul api.
varconsulClient=newConsulClient();varsubscriber=newConsulServiceSubscriber(client,"FooService",newList<string>(),true,false);varendpoints=subscriber.Endpoints();Since the Consul api supports long polling, we can cache the results and provide a background process to poll for changes.
varconsulClient=newConsulClient();varsubscriber=newConsulServiceSubscriber(client,"FooService",newList<string>(),true,true);varcache=newMemoryCache(newMemoryCacheOptions());varloggerFactory=newLoggerFactory();varpollingSubscriber=newCacheServiceSubscriber(loggerFactory,subscriber,cache);varendpoints=pollingSubscriber.Endpoints();The caching implementation in combination with the throttle implementation can be used for any service discovery platform that does not support long polling. The throttler is useful also to prevent overloading your service discovery platform with requests.
varconsulClient=newConsulClient();varsubscriber=newConsulServiceSubscriber(client,"FooService",newList<string>(),true,true);// Limit to 5 requests per 10 secondsvarthrottleSubscriber=newThrottleServiceSubscriber(subscriber,5,TimeSpan.FromSeconds(10))varloggerFactory=newLoggerFactory();varcache=newMemoryCache(newMemoryCacheOptions());varpollingSubscriber=newCacheServiceSubscriber(throttleSubscriber,loggerFactory,cache);varendpoints=pollingSubscriber.Endpoints();