Documentation
¶
Index ¶
- Constants
- type Client
- func (client *Client) Debug(debug bool)
- func (client *Client) Deregister(id string) error
- func (client *Client) ListInstances() ([]*api.ServiceInstance, error)
- func (client *Client) ListInstancesWithFilter(filter InstanceFilter) ([]*api.ServiceInstance, error)
- func (client *Client) ListServiceInstances(serviceName string) ([]*api.ServiceInstance, error)
- func (client *Client) ListServices() ([]string, error)
- func (client *Client) Register(instance *api.ServiceInstance) (*api.ServiceInstance, error)
- func (client *Client) Renew(id string) error
- type Config
- type Error
- type ErrorCode
- type InstanceFilter
Constants ¶
const ( FieldID = "id" FieldServiceName = "service_name" FieldEndpoint = "endpoint" FieldStatus = "status" FieldTags = "tags" FieldMetadata = "metadata" FieldTTL = "ttl" FieldLastHeartbeat = "last_heartbeat" )
Enumerates available values for InstanceField.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the ServiceDiscovery and ServiceRegistry interfaces using Amalgam8 Registry REST API.
func New ¶
New constructs a new Client using the given configuration.
func (*Client) Debug ¶ added in v1.0.0
Debug is used to set the debugging flag.
func (*Client) Deregister ¶ added in v1.0.0
Deregister removes a registered service instance, identified by the given ID, from the registry.
func (*Client) ListInstances ¶ added in v1.0.0
func (client *Client) ListInstances() ([]*api.ServiceInstance, error)
ListInstances queries for the list of service instances currently registered.
func (*Client) ListInstancesWithFilter ¶ added in v1.0.0
func (client *Client) ListInstancesWithFilter(filter InstanceFilter) ([]*api.ServiceInstance, error)
ListInstancesWithFilter queries for the list of service instances currently registered that satisfy the given filter.
func (*Client) ListServiceInstances ¶ added in v1.0.0
func (client *Client) ListServiceInstances(serviceName string) ([]*api.ServiceInstance, error)
ListServiceInstances queries for the list of service instances currently registered for the given service.
func (*Client) ListServices ¶ added in v1.0.0
ListServices queries for the list of services for which instances are currently registered.
func (*Client) Register ¶ added in v1.0.0
func (client *Client) Register(instance *api.ServiceInstance) (*api.ServiceInstance, error)
Register adds a service instance, described by the given ServiceInstance structure, to the registry.
type Config ¶
type Config struct {
// URL of the registry server.
URL string
// AuthToken is the bearer token to be used for authentication with the registry.
// If left empty, no authentication is used.
AuthToken string
// HTTPClient can be used to customize the underlying HTTP client behavior,
// such as enabling TLS, setting timeouts, etc.
// If left nil, a default HTTP client will be used.
HTTPClient *http.Client
}
Config stores the configurable attributes of the client.
type Error ¶
Error represents an actual error occurred which using the client.
type ErrorCode ¶
type ErrorCode int
ErrorCode represents an error condition which might occur when using the client.
type InstanceFilter ¶
type InstanceFilter struct {
// ServiceName is used to filter service instances based on their service name.
// When set to a non-empty string, registered service instances will be returned
// only if their service name matches the specified service name.
ServiceName string
// Status is used to filter service instances based on their status.
// When set to a non-empty string, registered service instances will be returned
// only if their status matches the specified status.
// When left empty, only instances with status "UP" will be returned.
// When set to "ALL", all instances will be returned, regardless of their status.
Status string
// Tags is used to filter service instances based on their tags.
// When set to a non-empty array, registered service instances will be returned
// only if they are tagged with each of the specified tags.
Tags []string
// Fields is used to filter the fields returned for each service instance.
// When set to a non-empty array, returned service instances will have their corresponding fields set,
// while other fields will remain at their zero-value.
// When set to an empty or nil array, returned service instances will have all of their fields set.
Fields []string
}
InstanceFilter is used to filter service instances returned from lookup calls.
The zero-value indicates to use the registry's default filtering, which includes all service instances with status 'UP', and include all fields in the response.
Source Files
¶
- client.go
- errors.go
- filter.go