Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrWatcherClosed = errors.New("watcher closed")
)
Functions ¶
Types ¶
type Agent ¶
type Agent interface { // Register adds a new service to the catalogue Register(ctx context.Context, s *Registration) (string, error) // Deregister removes a service from the catalogue // If the service does not exist, no action is taken. Deregister(ctx context.Context, id string) error // Services returns all registered service instances Services(ctx context.Context, tags ...string) (map[string]Service, error) // Service returns all instances of a service Service(ctx context.Context, name string, tags ...string) (Service, error) // Leave is used to have the agent de-register all services from the catalogue // that belong to this node, and gracefully leave Leave(ctx context.Context) }
An Agent interacts with a service discovery cluster to manage all services offered by the local node. It also allows to query the service discovery cluster to fetch services offered by other nodes.
func AgentFromContext ¶
AgentFromContext returns an `Agent` instance associated with `ctx`, or the local `Agent` if no instance could be found.
func NewLocalAgent ¶
func NewLocalAgent() Agent
NewLocalAgent returns a new local-only service discovery agent. This agent is used when service discovery is disabled.
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
Diff stores a snapshot of instances and generate all events needed to go from one snapshot to the other. This simplifies the development of adapters that don't support incremental updates.
type Event ¶
type Event struct { // Op indicates the operation of the update. Op Operation // Instance is the updated instance. Instance *Instance }
Event defines an instance event
type Instance ¶
type Instance struct { // Local tells whether it is a local or remote instance Local bool // ID is the unique instance identifier ID string // Name of the service Name string // Host is the IP address or DNS name Host string // Port defines the port on which the service runs Port uint16 // Tags of that instance Tags []string }
An Instance is an instance of a remotely-accessible service on the network
type Operation ¶
type Operation uint8
Operation defines the corresponding operations for a service update
type Registration ¶
type Registration struct { // ID is the unique identifier for the service (optional) ID string // Name is the service name Name string Addr string Port uint16 Tags []string }
Registration allows to register a service
type Service ¶
type Service interface { // Name returns the unique name of a service Name() string // Watch listens to service updates Watch() Watcher // Instances returns all available instances of the service Instances() []*Instance }
A Service is a set of functionalities offered by one or multiple nodes on the network. A node that offers the service is called an instance. A node can offer multiple services, so there will be multiple instances on the same node.
type Watcher ¶
type Watcher interface { // Next blocks until an event or error happens. It may return one or more // events. The first call should get the full set of the results. It should // return an error if and only if Watcher cannot recover. Next() ([]*Event, error) // Close closes the Watcher. Close() error }
Watcher watches for the updates on the specified service
Directories ¶
Path | Synopsis |
---|---|
consul
Package consul is a wrapper around the Hashicorp Consul service discovery functionnality Consul is a highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy.
|
Package consul is a wrapper around the Hashicorp Consul service discovery functionnality Consul is a highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy. |