worker

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MPL-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The base Server object, containing things shared between Controllers and
	// Workers
	*base.Server
	// The underlying configuration, passed in here to avoid duplicating values
	// everywhere
	RawConfig *config.Config
}

type HandlerProperties

type HandlerProperties struct {
	ListenerConfig *listenerutil.ListenerConfig
}

type LastStatusInformation

type LastStatusInformation struct {
	*pbs.StatusResponse
	StatusTime time.Time
}

type TestConnectionInfo added in v0.4.0

type TestConnectionInfo struct {
	Id        string
	Status    pbs.CONNECTIONSTATUS
	CloseTime time.Time
}

TestConnectionInfo provides detail about a particular connection as a part of TestSessionInfo. See that struct for details about the purpose of this data and how it's gathered.

type TestSessionInfo added in v0.4.0

type TestSessionInfo struct {
	Id     string
	Status pbs.SESSIONSTATUS

	// Connections is indexed by connection ID, which is also included
	// within TestConnectionInfo for convenience.
	Connections map[string]TestConnectionInfo
}

TestSessionInfo provides detail about a particular session from the worker's local session state. This detail is a point-in-time snapshot of what's in sessionInfoMap for a particular session, and may not contain all of the information that is contained within it, or the underlying ConnInfoMap. Only details that are really important to testing are passed along.

type TestWorker

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

TestWorker wraps a base.Server and Worker to provide a fully-programmatic worker for tests. Error checking (for instance, for valid config) is not stringent at the moment.

func NewTestWorker

func NewTestWorker(t *testing.T, opts *TestWorkerOpts) *TestWorker

func (*TestWorker) AddClusterWorkerMember

func (tw *TestWorker) AddClusterWorkerMember(t *testing.T, opts *TestWorkerOpts) *TestWorker

func (*TestWorker) Cancel

func (tw *TestWorker) Cancel()

func (*TestWorker) Config

func (tw *TestWorker) Config() *Config

func (*TestWorker) Context

func (tw *TestWorker) Context() context.Context

func (*TestWorker) ControllerAddrs

func (tw *TestWorker) ControllerAddrs() []string

func (*TestWorker) LookupSession added in v0.4.0

func (tw *TestWorker) LookupSession(id string) (TestSessionInfo, bool)

LookupSession returns session info from the worker's local session state.

The return boolean will be true if the session was found, false if it wasn't.

See TestSessionInfo for details on how to use this info.

func (*TestWorker) Name

func (tw *TestWorker) Name() string

func (*TestWorker) ProxyAddrs

func (tw *TestWorker) ProxyAddrs() []string

func (*TestWorker) Shutdown

func (tw *TestWorker) Shutdown()

Shutdown runs any cleanup functions; be sure to run this after your test is done

func (*TestWorker) Worker

func (tw *TestWorker) Worker() *Worker

Worker returns the underlying controller

type TestWorkerOpts

type TestWorkerOpts struct {
	// Config; if not provided a dev one will be created
	Config *config.Config

	// Sets initial controller addresses
	InitialControllers []string

	// If true, the worker will not be started
	DisableAutoStart bool

	// The worker auth KMS to use, or one will be created
	WorkerAuthKms wrapping.Wrapper

	// The name to use for the worker, otherwise one will be randomly
	// generated, unless provided in a non-nil Config
	Name string

	// The logger to use, or one will be created
	Logger hclog.Logger

	// The amount of time to wait before marking connections as closed when a
	// connection cannot be made back to the controller
	StatusGracePeriodDuration time.Duration

	// Whether to set the replay value
	EnableAuthReplay bool
}

type Worker

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

func New

func New(conf *Config) (*Worker, error)

func (*Worker) ControllerSessionConn added in v0.5.1

func (w *Worker) ControllerSessionConn() (pbs.SessionServiceClient, error)

func (*Worker) LastStatusSuccess

func (w *Worker) LastStatusSuccess() *LastStatusInformation

LastStatusSuccess reports the last time we sent a successful status request.

func (*Worker) ParseAndStoreTags added in v0.1.8

func (w *Worker) ParseAndStoreTags(incoming map[string][]string)

func (*Worker) Resolver

func (w *Worker) Resolver() *manual.Resolver

func (*Worker) Shutdown

func (w *Worker) Shutdown(skipListeners bool) error

Shutdown shuts down the workers. skipListeners can be used to not stop listeners, useful for tests if we want to stop and start a worker. In order to create new listeners we'd have to migrate listener setup logic here -- doable, but work for later.

func (*Worker) Start

func (w *Worker) Start() error

func (*Worker) WaitForNextSuccessfulStatusUpdate added in v0.5.0

func (w *Worker) WaitForNextSuccessfulStatusUpdate() error

WaitForNextSuccessfulStatusUpdate waits for the next successful status. It's used by testing (and in the future, shutdown) in place of a more opaque and possibly unnecessarily long sleep for things like initial controller check-in, etc.

The timeout is aligned with the worker's status grace period. A nil error means the status was sent successfully.

Directories

Path Synopsis
Package common contains types and helper functions that are used across the different packages under internal/server/worker.
Package common contains types and helper functions that are used across the different packages under internal/server/worker.
Package proxy contains a collection of proxy handlers for the worker to call once a connection has been authorized.
Package proxy contains a collection of proxy handlers for the worker to call once a connection has been authorized.
tcp

Jump to

Keyboard shortcuts

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