Documentation ¶
Overview ¶
Package discovery provides mechanisms for discovery of config API servers.
Index ¶
- func DefaultDialer(ctx context.Context, t *Target) (*grpc.ClientConn, error)
- type Application
- type ApplicationExecutor
- type ApplicationObserver
- type ApplicationObserverSet
- func (s *ApplicationObserverSet) ApplicationAvailable(a *Application)
- func (s *ApplicationObserverSet) ApplicationUnavailable(a *Application)
- func (s *ApplicationObserverSet) RegisterApplicationObserver(o ApplicationObserver)
- func (s *ApplicationObserverSet) UnregisterApplicationObserver(o ApplicationObserver)
- type ApplicationTask
- type Client
- type ClientExecutor
- type ClientObserver
- type ClientObserverSet
- type ClientTask
- type Connector
- type Dialer
- type Inspector
- type MetaData
- type Target
- type TargetExecutor
- type TargetObserver
- type TargetObserverSet
- type TargetTask
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDialer ¶
DefaultDialer is the default dialer used to connect to a gRPC target.
Types ¶
type Application ¶ added in v0.4.0
type Application struct { configkit.Application // Client is the client that queried the application configuration. Client *Client }
Application is an application configuration that is aware of the client it was obtained from.
type ApplicationExecutor ¶ added in v0.4.0
type ApplicationExecutor struct { // Task is the function to execute when an application becomes available. // The context is canceled when the application becomes unavailable. Task ApplicationTask // Parent is the parent context under which the function is called. // If it is nil, context.Background() is used. Parent context.Context // contains filtered or unexported fields }
ApplicationExecutor is an ApplicationObserver that executes a function in a new goroutine whenever an application becomes available.
func (*ApplicationExecutor) ApplicationAvailable ¶ added in v0.4.0
func (e *ApplicationExecutor) ApplicationAvailable(a *Application)
ApplicationAvailable starts a new goroutine for the given application.
func (*ApplicationExecutor) ApplicationUnavailable ¶ added in v0.4.0
func (e *ApplicationExecutor) ApplicationUnavailable(a *Application)
ApplicationUnavailable cancels the context associated with any existing goroutine for the given application and waits for the goroutine to exit.
type ApplicationObserver ¶ added in v0.4.0
type ApplicationObserver interface { // ApplicationAvailable is called when an application becomes available. ApplicationAvailable(*Application) ApplicationUnavailable(*Application) }
ApplicationObserver is notified when Dogma applications are discovered.
type ApplicationObserverSet ¶ added in v0.4.0
type ApplicationObserverSet struct {
// contains filtered or unexported fields
}
ApplicationObserverSet is an ApplicationObserver that publishes to other observers.
func NewApplicationObserverSet ¶ added in v0.4.0
func NewApplicationObserverSet(observers ...ApplicationObserver) *ApplicationObserverSet
NewApplicationObserverSet registers the given observers with a new observer set and returns it.
func (*ApplicationObserverSet) ApplicationAvailable ¶ added in v0.4.0
func (s *ApplicationObserverSet) ApplicationAvailable(a *Application)
ApplicationAvailable notifies the registered observers that a is available.
func (*ApplicationObserverSet) ApplicationUnavailable ¶ added in v0.4.0
func (s *ApplicationObserverSet) ApplicationUnavailable(a *Application)
ApplicationUnavailable notifies the registered observers that a is unavailable.
func (*ApplicationObserverSet) RegisterApplicationObserver ¶ added in v0.4.0
func (s *ApplicationObserverSet) RegisterApplicationObserver(o ApplicationObserver)
RegisterApplicationObserver registers o to be notified when applications become available and unavailable.
func (*ApplicationObserverSet) UnregisterApplicationObserver ¶ added in v0.4.0
func (s *ApplicationObserverSet) UnregisterApplicationObserver(o ApplicationObserver)
UnregisterApplicationObserver stops o from being notified when applications become available and unavailable.
type ApplicationTask ¶ added in v0.4.0
type ApplicationTask func(context.Context, *Application)
ApplicationTask is a function executed by an ApplicationExecutor.
type Client ¶
type Client struct { api.Client // Target is the discovered gRPC target that the client connects to. Target *Target // Connection is the gRPC connection to the target. Connection *grpc.ClientConn }
Client is an API client that is aware of the target it connects to.
type ClientExecutor ¶ added in v0.4.0
type ClientExecutor struct { // Task is the function to execute when a client connects. // The context is canceled when the target becomes unavailable. Task ClientTask // Parent is the parent context under which the function is called. // If it is nil, context.Background() is used. Parent context.Context // contains filtered or unexported fields }
ClientExecutor is a ClientObserver that executes a function in a new goroutine whenever a client connects.
func (*ClientExecutor) ClientConnected ¶ added in v0.4.0
func (e *ClientExecutor) ClientConnected(c *Client)
ClientConnected starts a new goroutine for the given client.
func (*ClientExecutor) ClientDisconnected ¶ added in v0.4.0
func (e *ClientExecutor) ClientDisconnected(c *Client)
ClientDisconnected cancels the context associated with any existing goroutine for the given client and waits for the goroutine to exit.
type ClientObserver ¶
type ClientObserver interface { // ClientConnected is called when a connection to a config API server is // established. ClientConnected(*Client) // ClientDisconnected is called when a connection to a config API server is // severed. ClientDisconnected(*Client) }
ClientObserver is notified when connections to config API servers are established and severed.
type ClientObserverSet ¶
type ClientObserverSet struct {
// contains filtered or unexported fields
}
ClientObserverSet is a ClientObserver that publishes to other observers.
func NewClientObserverSet ¶
func NewClientObserverSet(observers ...ClientObserver) *ClientObserverSet
NewClientObserverSet registers the given observers with a new observer set and returns it.
func (*ClientObserverSet) ClientConnected ¶
func (s *ClientObserverSet) ClientConnected(c *Client)
ClientConnected notifies the registered observers that c has connected.
func (*ClientObserverSet) ClientDisconnected ¶
func (s *ClientObserverSet) ClientDisconnected(c *Client)
ClientDisconnected notifies the registered observers that c has disconnected.
func (*ClientObserverSet) RegisterClientObserver ¶
func (s *ClientObserverSet) RegisterClientObserver(o ClientObserver)
RegisterClientObserver registers o to be notified when connections to config API servers are established and servered.
func (*ClientObserverSet) UnregisterClientObserver ¶
func (s *ClientObserverSet) UnregisterClientObserver(o ClientObserver)
UnregisterClientObserver stops o from being notified when connections to config API servers are established and servered.
type ClientTask ¶ added in v0.4.0
ClientTask is a function executed by a ClientExecutor.
type Connector ¶
type Connector struct { // Observer is notified when a config API client connects to or disconnects // from a server. It must not be nil. Observer ClientObserver // Dial is the dialer used to connect to the discovered targets. // If it is nil, DefaultDialer is used. Dial Dialer // Ignore is a predicate function that returns true if the given target // should be ignored. Ignore func(*Target) bool // BackoffStrategy controls how long to wait between dialing retries. BackoffStrategy backoff.Strategy // IsFatal, if non-nil, is called when an error occurs connecting to a // target. // // If it returns true, Run() returns err immediately. If it is nil, or it // returns false, dialing is retried as per the backoff strategy. IsFatal func(err error) bool }
Connector connects to discovered targets and notifies a client observer if they implement the config API.
type Inspector ¶ added in v0.4.0
type Inspector struct { // Observer is notified when an application is discovered via a config API // client. It must not be nil. Observer ApplicationObserver // Ignore is a predicate function that returns true if the given application // should be ignored. Ignore func(*Application) bool // BackoffStrategy controls how long to wait between inspection retries. BackoffStrategy backoff.Strategy // IsFatal, if non-nil, is called when an error occurs listing the // applications for a client. // // If it returns true, Run() returns err immediately. If it is nil, or it // returns false, inspections are retried as per the backoff strategy. IsFatal func(err error) bool }
Inspector queries connected clients and notifies an application observer of the applications it has.
func (*Inspector) Run ¶ added in v0.4.0
Run queries a client in order to publish application available/unavailable notifications to the observer.
It retries until the applications are successfully discovered. After which it blocks until ctx is canceled, or returns immediately if no applications were found.
type MetaData ¶
type MetaData map[interface{}]interface{}
MetaData is a container for meta-data about a target.
type Target ¶
type Target struct { // Name is the target name used to dial the endpoint. The syntax is defined // in https://github.com/grpc/grpc/blob/master/doc/naming.md. Name string // Options is a set of grpc.DialOptions used when dialing this target. // The options must not include grpc.WithBlock(). Options []grpc.DialOption // MetaData contains driver-specific meta-data about the target. MetaData MetaData }
Target represents some dialable gRPC target, typically a single gRPC server.
type TargetExecutor ¶ added in v0.4.0
type TargetExecutor struct { // Task is the function to execute when a target becomes available. // The context is canceled when the target becomes unavailable. Task TargetTask // Parent is the parent context under which the function is called. // If it is nil, context.Background() is used. Parent context.Context // contains filtered or unexported fields }
TargetExecutor is a TargetObserver that executes a function in a new goroutine whenever a target becomes available.
func (*TargetExecutor) TargetAvailable ¶ added in v0.4.0
func (e *TargetExecutor) TargetAvailable(t *Target)
TargetAvailable starts a new goroutine for the given target.
func (*TargetExecutor) TargetUnavailable ¶ added in v0.4.0
func (e *TargetExecutor) TargetUnavailable(t *Target)
TargetUnavailable cancels the context associated with any existing goroutine for the given target and waits for the goroutine to exit.
type TargetObserver ¶
type TargetObserver interface { // TargetAvailable is called when a target becomes available. TargetAvailable(*Target) TargetUnavailable(*Target) }
TargetObserver is notified when config API targets are discovered.
type TargetObserverSet ¶
type TargetObserverSet struct {
// contains filtered or unexported fields
}
TargetObserverSet is a TargetObserver that publishes to other observers.
func NewTargetObserverSet ¶
func NewTargetObserverSet(observers ...TargetObserver) *TargetObserverSet
NewTargetObserverSet registers the given observers with a new observer set and returns it.
func (*TargetObserverSet) RegisterTargetObserver ¶
func (s *TargetObserverSet) RegisterTargetObserver(o TargetObserver)
RegisterTargetObserver registers o to be notified when targets become available and unavailable.
func (*TargetObserverSet) TargetAvailable ¶
func (s *TargetObserverSet) TargetAvailable(t *Target)
TargetAvailable notifies the registered observers that t is available.
func (*TargetObserverSet) TargetUnavailable ¶
func (s *TargetObserverSet) TargetUnavailable(t *Target)
TargetUnavailable notifies the registered observers that t is unavailable.
func (*TargetObserverSet) UnregisterTargetObserver ¶
func (s *TargetObserverSet) UnregisterTargetObserver(o TargetObserver)
UnregisterTargetObserver stops o from being notified when targets become available and unavailable.
type TargetTask ¶ added in v0.4.0
TargetTask is a function executed by a TargetExecutor.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package simpledns discovers config API servers by performing simple DNS queries.
|
Package simpledns discovers config API servers by performing simple DNS queries. |
Package static "discovers" a static list of config API servers.
|
Package static "discovers" a static list of config API servers. |