Documentation ¶
Overview ¶
Package nsd provides Nomad service registration and therefore discovery capabilities for Nomad clients. The name nsd was used instead of Nomad to avoid conflict with the existing nomad package.
Index ¶
- func NewServiceRegistrationHandler(log hclog.Logger, cfg *ServiceRegistrationHandlerCfg) serviceregistration.Handler
- type ServiceRegistrationHandler
- func (s *ServiceRegistrationHandler) AllocRegistrations(_ string) (*serviceregistration.AllocRegistration, error)
- func (s *ServiceRegistrationHandler) RegisterWorkload(workload *serviceregistration.WorkloadServices) error
- func (s *ServiceRegistrationHandler) RemoveWorkload(workload *serviceregistration.WorkloadServices)
- func (s *ServiceRegistrationHandler) Shutdown()
- func (s *ServiceRegistrationHandler) UpdateTTL(_, _, _, _ string) error
- func (s *ServiceRegistrationHandler) UpdateWorkload(old, new *serviceregistration.WorkloadServices) error
- type ServiceRegistrationHandlerCfg
- type StatusGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServiceRegistrationHandler ¶
func NewServiceRegistrationHandler(log hclog.Logger, cfg *ServiceRegistrationHandlerCfg) serviceregistration.Handler
NewServiceRegistrationHandler returns a ready to use ServiceRegistrationHandler which implements the serviceregistration.Handler interface.
Types ¶
type ServiceRegistrationHandler ¶
type ServiceRegistrationHandler struct {
// contains filtered or unexported fields
}
func (*ServiceRegistrationHandler) AllocRegistrations ¶
func (s *ServiceRegistrationHandler) AllocRegistrations(_ string) (*serviceregistration.AllocRegistration, error)
AllocRegistrations is currently a noop implementation as the Nomad provider does not support health check which is the sole subsystem caller of this function.
func (*ServiceRegistrationHandler) RegisterWorkload ¶
func (s *ServiceRegistrationHandler) RegisterWorkload(workload *serviceregistration.WorkloadServices) error
func (*ServiceRegistrationHandler) RemoveWorkload ¶
func (s *ServiceRegistrationHandler) RemoveWorkload(workload *serviceregistration.WorkloadServices)
RemoveWorkload iterates the services and removes them from the service registration state.
This function works regardless of whether the client has this feature enabled. This covers situations where the feature is disabled, yet still has allocations which, when stopped need their registrations removed.
func (*ServiceRegistrationHandler) Shutdown ¶
func (s *ServiceRegistrationHandler) Shutdown()
Shutdown is used to initiate shutdown of the handler. This is specifically used to exit any routines running retry functions without leaving them orphaned.
func (*ServiceRegistrationHandler) UpdateTTL ¶
func (s *ServiceRegistrationHandler) UpdateTTL(_, _, _, _ string) error
UpdateTTL is currently a noop implementation as the Nomad provider does not support health check which is the sole subsystem caller of this function.
func (*ServiceRegistrationHandler) UpdateWorkload ¶
func (s *ServiceRegistrationHandler) UpdateWorkload(old, new *serviceregistration.WorkloadServices) error
type ServiceRegistrationHandlerCfg ¶
type ServiceRegistrationHandlerCfg struct { // Enabled tracks whether this client feature is enabled. Enabled bool // Datacenter, NodeID, and Region are all properties of the Nomad client // and are used to perform RPC requests. Datacenter string NodeID string Region string // NodeSecret is the secret ID of the node and is used to authenticate RPC // requests. NodeSecret string // RPCFn is the client RPC function which is used to perform client to // server service registration RPC calls. This RPC function has basic retry // functionality. RPCFn func(method string, args, resp interface{}) error // CheckWatcher watches checks of services in the Nomad service provider, // and restarts associated tasks in accordance with their check_restart stanza. CheckWatcher serviceregistration.CheckWatcher }
ServiceRegistrationHandlerCfg holds critical information used during the normal process of the ServiceRegistrationHandler. It is used to keep the NewServiceRegistrationHandler function signature small and easy to modify.
type StatusGetter ¶
type StatusGetter struct {
// contains filtered or unexported fields
}
StatusGetter is the implementation of CheckStatusGetter for Nomad services.
func NewStatusGetter ¶
func NewStatusGetter(shim checkstore.Shim) *StatusGetter