{"modulePath":"github.com/zencoder/kit","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sd\n\nPackage sd provides utilities related to service discovery. That includes the client-side loadbalancer pattern, where a microservice subscribes to a service discovery system in order to reach remote instances; as well as the registrator pattern, where a microservice registers itself in a service discovery system. Implementations are provided for most common systems.\n\n## Types\n\n```go\ntype Factory func(instance string) (endpoint.Endpoint, io.Closer, error)\n```\nFactory is a function that converts an instance string (e.g. host:port) to a specific endpoint. Instances that provide multiple endpoints require multiple factories. A factory also returns an io.Closer that's invoked when the instance goes away and needs to be cleaned up. Factories may return nil closers.\n\nUsers are expected to provide their own factory functions that assume specific transports, or can deduce transports by parsing the instance string.\n\n```go\ntype FixedSubscriber []endpoint.Endpoint\n```\nFixedSubscriber yields a fixed set of services.\n\n```go\nfunc (s FixedSubscriber) Endpoints() ([]endpoint.Endpoint, error)\n```\nEndpoints implements Subscriber.\n\n```go\ntype Registrar interface {\n\tRegister()\n\tDeregister()\n}\n```\nRegistrar registers instance information to a service discovery system when an instance becomes alive and healthy, and deregisters that information when the service becomes unhealthy or goes away.\n\nRegistrar implementations exist for various service discovery systems. Note that identifying instance information (e.g. host:port) must be given via the concrete constructor; this interface merely signals lifecycle changes.\n\n```go\ntype Subscriber interface {\n\tEndpoints() ([]endpoint.Endpoint, error)\n}\n```\nSubscriber listens to a service discovery system and yields a set of identical endpoints on demand. An error indicates a problem with connectivity to the service discovery system, or within the system itself; a subscriber may yield no endpoints without error.\n\n","path":"github.com/zencoder/kit/sd","name":"sd","synopsis":"Package sd provides utilities related to service discovery.","isRedistributable":true}
