Documentation ¶
Index ¶
- type Client
- func (c *Client) Deregister(_ context.Context, serviceID string) error
- func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enableHealthCheck bool) error
- func (c *Client) Service(ctx context.Context, service string, index uint64, passingOnly bool) ([]*registry.ServiceInstance, uint64, error)
- type Config
- type Datacenter
- type Option
- func WithDatacenter(dc Datacenter) Option
- func WithDeregisterCriticalServiceAfter(interval int) Option
- func WithHealthCheck(enable bool) Option
- func WithHealthCheckInterval(interval int) Option
- func WithHeartbeat(enable bool) Option
- func WithServiceCheck(checks ...*api.AgentServiceCheck) Option
- func WithServiceResolver(fn ServiceResolver) Option
- func WithTimeout(timeout time.Duration) Option
- type Registry
- func (r *Registry) Deregister(ctx context.Context, svc *registry.ServiceInstance) error
- func (r *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error)
- func (r *Registry) ListServices() (allServices map[string][]*registry.ServiceInstance, err error)
- func (r *Registry) Register(ctx context.Context, svc *registry.ServiceInstance) error
- func (r *Registry) Watch(ctx context.Context, name string) (registry.Watcher, error)
- type ServiceResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is consul client config
func (*Client) Deregister ¶
Deregister service by service ID
type Datacenter ¶
type Datacenter string
const ( SingleDatacenter Datacenter = "SINGLE" MultiDatacenter Datacenter = "MULTI" )
type Option ¶
type Option func(*Registry)
Option is consul registry option.
func WithDatacenter ¶
func WithDatacenter(dc Datacenter) Option
WithDatacenter with registry datacenter option
func WithDeregisterCriticalServiceAfter ¶
WithDeregisterCriticalServiceAfter with deregister-critical-service-after in seconds.
func WithHealthCheck ¶
WithHealthCheck with registry health check option.
func WithHealthCheckInterval ¶
WithHealthCheckInterval with healthcheck interval in seconds.
func WithHeartbeat ¶
WithHeartbeat enable or disable heartbeat
func WithServiceCheck ¶
func WithServiceCheck(checks ...*api.AgentServiceCheck) Option
WithServiceCheck with service checks
func WithServiceResolver ¶
func WithServiceResolver(fn ServiceResolver) Option
WithServiceResolver with endpoint function option.
func WithTimeout ¶
WithTimeout with get services timeout option.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is consul registry
func (*Registry) Deregister ¶
Deregister deregister service
func (*Registry) GetService ¶
func (r *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error)
GetService return service by name
func (*Registry) ListServices ¶
func (r *Registry) ListServices() (allServices map[string][]*registry.ServiceInstance, err error)
ListServices return service list.
type ServiceResolver ¶
type ServiceResolver func(ctx context.Context, entries []*api.ServiceEntry) []*registry.ServiceInstance
ServiceResolver is used to resolve service endpoints