nsd

package
v1.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: MPL-2.0 Imports: 10 Imported by: 1

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

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

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 (*ServiceRegistrationHandler) RemoveWorkload

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

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 block.
	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 added in v1.4.0

type StatusGetter struct {
	// contains filtered or unexported fields
}

StatusGetter is the implementation of CheckStatusGetter for Nomad services.

func NewStatusGetter added in v1.4.0

func NewStatusGetter(shim checkstore.Shim) *StatusGetter

func (StatusGetter) Get added in v1.4.0

func (s StatusGetter) Get() (map[string]string, error)

Get returns current status of every live check in the Nomad service provider.

returns checkID => checkStatus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL