@@ -6,11 +6,13 @@ import (
|
||||
|
||||
type registryKey struct{}
|
||||
|
||||
// FromContext get registry from context
|
||||
func FromContext(ctx context.Context) (Registry, bool) {
|
||||
c, ok := ctx.Value(registryKey{}).(Registry)
|
||||
return c, ok
|
||||
}
|
||||
|
||||
// NewContext put registry in context
|
||||
func NewContext(ctx context.Context, c Registry) context.Context {
|
||||
return context.WithValue(ctx, registryKey{}, c)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ var (
|
||||
ErrWatcherStopped = errors.New("watcher stopped")
|
||||
)
|
||||
|
||||
// The registry provides an interface for service discovery
|
||||
// Registry provides an interface for service discovery
|
||||
// and an abstraction over varying implementations
|
||||
// {consul, etcd, zookeeper, ...}
|
||||
type Registry interface {
|
||||
@@ -64,7 +64,7 @@ type Endpoint struct {
|
||||
Metadata metadata.Metadata `json:"metadata"`
|
||||
}
|
||||
|
||||
// Valud holds additional kv stuff
|
||||
// Value holds additional kv stuff
|
||||
type Value struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
|
||||
Reference in New Issue
Block a user