registration

package
v0.2012.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CfgRegistrationEntity configures the registration worker entity.
	CfgRegistrationEntity = "worker.registration.entity"
	// CfgDebugRegistrationPrivateKey configures the registration worker private key.
	CfgDebugRegistrationPrivateKey = "worker.registration.debug.private_key"
	// CfgRegistrationForceRegister overrides a previously saved deregistration
	// request.
	CfgRegistrationForceRegister = "worker.registration.force_register"
	// CfgRegistrationRotateCerts sets the number of epochs that a node's TLS
	// certificate should be valid for.
	CfgRegistrationRotateCerts = "worker.registration.rotate_certs"
)

Variables

View Source
var (

	// Flags has the configuration flags.
	Flags = flag.NewFlagSet("", flag.ContinueOnError)
)

Functions

func DebugForceAllowUnroutableAddresses

func DebugForceAllowUnroutableAddresses()

DebugForceallowUnroutableAddresses allows unroutable addresses.

func GetRegistrationSigner

func GetRegistrationSigner(logger *logging.Logger, dataDir string, identity *identity.Identity) (signature.PublicKey, signature.Signer, error)

GetRegistrationSigner loads the signing credentials as configured by this package's flags.

Types

type Delegate

type Delegate interface {
	// RegistrationStopped is called by the worker when the registration loop exits cleanly.
	RegistrationStopped()
}

Delegate is the interface for objects that wish to know about the worker's events.

type RegisterNodeCallback

type RegisterNodeCallback func(context.Context) error

RegisterNodeCallback is a function that is called after a successful registration.

type RegisterNodeHook

type RegisterNodeHook func(*node.Node) error

RegisterNodeHook is a function that is used to update the node descriptor.

type RoleProvider

type RoleProvider interface {
	// SetAvailable signals that the role provider is available and that node registration can
	// thus proceed.
	SetAvailable(hook RegisterNodeHook)

	// SetAvailableWithCallback signals that the role provider is available and that node
	// registration can thus proceed.
	//
	// If the passed cb is non-nil, it will be called once after the next successful registration
	// that includes the node descriptor updated by the passed hook.
	SetAvailableWithCallback(hook RegisterNodeHook, cb RegisterNodeCallback)

	// SetUnavailable signals that the role provider is unavailable and that node registration
	// should be blocked until the role provider becomes available.
	SetUnavailable()
}

RoleProvider is the node descriptor role provider interface.

It is used to reserve a slot in the node descriptor that will be filled when the role provider decides that it is available. This is used so that the registration worker knows when certain roles are ready to be serviced by the node.

An unavailable role provider will prevent the node from being (re-)registered.

type Worker

type Worker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Worker is a service handling worker node registration.

func New

func New(
	dataDir string,
	epochtime epochtime.Backend,
	registry registry.Backend,
	identity *identity.Identity,
	consensus consensus.Backend,
	p2p *p2p.P2P,
	workerCommonCfg *workerCommon.Config,
	store *persistent.CommonStore,
	delegate Delegate,
	runtimeRegistry runtimeRegistry.Registry,
) (*Worker, error)

New constructs a new worker node registration service.

func (*Worker) Cleanup

func (w *Worker) Cleanup()

Cleanup performs the service specific post-termination cleanup.

func (*Worker) GetRegistrationStatus

func (w *Worker) GetRegistrationStatus(ctx context.Context) (*control.RegistrationStatus, error)

GetRegistrationStatus returns the node's current registration status.

func (*Worker) InitialRegistrationCh

func (w *Worker) InitialRegistrationCh() chan struct{}

InitialRegistrationCh returns the initial registration channel.

func (*Worker) Name

func (w *Worker) Name() string

Name returns the service name.

func (*Worker) NewRoleProvider

func (w *Worker) NewRoleProvider(role node.RolesMask) (RoleProvider, error)

NewRoleProvider creates a new role provider slot.

Each part of the code that wishes to contribute something to the node descriptor can use this method to ask the registration worker to create a slot. The slot can (later) be toggled to be either available or unavailable. An unavailable slot will prevent the node registration from taking place.

The returned role provider is in unavailable state.

func (*Worker) NewRuntimeRoleProvider

func (w *Worker) NewRuntimeRoleProvider(role node.RolesMask, runtimeID common.Namespace) (RoleProvider, error)

NewRuntimeRoleProvider creates a new runtime role provider slot.

Each part of the code that wishes to contribute something to the node descriptor can use this method to ask the registration worker to create a slot. The slot can (later) be toggled to be either available or unavailable. An unavailable slot will prevent the node registration from taking place.

The returned role provider is in unavailable state.

func (*Worker) Quit

func (w *Worker) Quit() <-chan struct{}

Quit returns a channel that will be closed when the service terminates.

func (*Worker) RequestDeregistration

func (w *Worker) RequestDeregistration() error

RequestDeregistration requests that the node not register itself in the next epoch.

func (*Worker) Start

func (w *Worker) Start() error

Start starts the registration service.

func (*Worker) Stop

func (w *Worker) Stop()

Stop halts the service.

Jump to

Keyboard shortcuts

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