handlers

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MPL-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewControllerUpstreamMessageServiceServer added in v0.13.0

func NewControllerUpstreamMessageServiceServer(
	ctx context.Context,
	storage nodeenrollment.Storage,
) (pbs.UpstreamMessageServiceServer, error)

NewControllerUpstreamMessageServiceServer creates a new service implementing UpstreamMessageServiceServer, storing values used for the implementing functions.

func NewMultihopServiceServer

func NewMultihopServiceServer(storage nodeenrollment.Storage, direct bool, client *atomic.Value, opt ...nodeenrollment.Option) (*multihopServiceServer, error)

NewMultihopServiceServer creates a new service implementing MultihopServiceServer, storing values used for the implementing functions.

func NewWorkerServiceServer

func NewWorkerServiceServer(
	serversRepoFn common.ServersRepoFactory,
	workerAuthRepoFn common.WorkerAuthRepoStorageFactory,
	sessionRepoFn session.RepositoryFactory,
	connectionRepoFn common.ConnectionRepoFactory,
	downstreams common.Downstreamers,
	updateTimes *sync.Map,
	kms *kms.Kms,
	livenessTimeToStale *atomic.Int64,
	controllerExt intglobals.ControllerExtension,
) *workerServiceServer

func NewWorkerUpstreamMessageServiceServer added in v0.13.0

func NewWorkerUpstreamMessageServiceServer(
	ctx context.Context,
	clientProducer UpstreamMessageServiceClientProducer,
) (*workerUpstreamMessageServiceServer, error)

NewWorkerUpstreamMessageServiceServer creates a new service implementing UpstreamMessageServiceServer, storing values used for the implementing functions.

func RegisterUpstreamMessageHandler added in v0.13.0

func RegisterUpstreamMessageHandler(ctx context.Context, msgType pbs.MsgType, h UpstreamMessageHandler) error

RegisterUpstreamMessageHandler will register an UpstreamMessageHandler for the specified msg name.

See controllerUpstreamMessageServiceServer.UpstreamMessage for how this is used to handle an UpstreamMessageRequest via registered upstream message handlers.

func SendUpstreamMessage added in v0.13.0

func SendUpstreamMessage(ctx context.Context, clientProducer UpstreamMessageServiceClientProducer, originatingWorkerKeyId string, msg proto.Message, opt ...Option) (proto.Message, error)

func TestRegisterHandlerFn added in v0.13.0

func TestRegisterHandlerFn(t *testing.T, msgType pbs.MsgType, h UpstreamMessageHandler) func(*testing.T)

TestRegisterHandlerFn returns a func that will register a handler for the test and then unregister it when the test is complete. This should not be used with t.Parallel() since it modifies the registered handlers for the pkg.

Types

type Option added in v0.13.0

type Option func(*options)

Option - how Options are passed as arguments

func WithKeyProducer added in v0.13.0

func WithKeyProducer(nodeInfo nodeenrollment.X25519KeyProducer) Option

WithKeyProducer provides an option types.NodeInformation

type TestMockEncryptedUpstreamMessageHandler added in v0.13.0

type TestMockEncryptedUpstreamMessageHandler struct {
	WantHandlerErr error
	WantResp       proto.Message
}

TestMockEncryptedUpstreamMessageHandler provides a test mock handler

func (*TestMockEncryptedUpstreamMessageHandler) AllocRequest added in v0.13.0

AllocRequest returns an allocated proto for the handler's request.

func (*TestMockEncryptedUpstreamMessageHandler) AllocResponse added in v0.13.0

AllocResponse returns an allocated proto for the handler's response.

func (*TestMockEncryptedUpstreamMessageHandler) Encrypted added in v0.13.0

Encrypted returns true; since the handler's request/response must be encrypted.

func (*TestMockEncryptedUpstreamMessageHandler) Handler added in v0.13.0

Handler implements the handler for the mock

type TestMockUpstreamMessageHandler added in v0.13.0

type TestMockUpstreamMessageHandler struct {
	WantHandlerErr error
	WantResp       proto.Message
}

TestMockUpstreamMessageHandler provides a test mock handler

func (*TestMockUpstreamMessageHandler) AllocRequest added in v0.13.0

AllocRequest returns an allocated proto for the handler's request.

func (*TestMockUpstreamMessageHandler) AllocResponse added in v0.13.0

func (*TestMockUpstreamMessageHandler) AllocResponse() proto.Message

AllocResponse returns an allocated proto for the handler's response.

func (*TestMockUpstreamMessageHandler) Encrypted added in v0.13.0

func (*TestMockUpstreamMessageHandler) Encrypted() bool

Encrypted returns false; since the handler's request/response must be encrypted.

func (*TestMockUpstreamMessageHandler) Handler added in v0.13.0

Handler implements the handler for the mock

type UpstreamMessageHandler added in v0.13.0

type UpstreamMessageHandler interface {
	// Handler for the request.  All errors returned must be a error created
	// using google.golang.org/grpc/status
	Handler(ctx context.Context, request proto.Message) (response proto.Message, statusErr error)

	UpstreamMessageTypeSpecifier
}

UpstreamMessageHandler defines a handler for an UpstreamMessageRequest(s).

See controllerUpstreamMessageServiceServer.UpstreamMessage for how this is used to handle an UpstreamMessageRequest via registered upstream message handlers.

type UpstreamMessageServiceClientProducer added in v0.13.0

type UpstreamMessageServiceClientProducer func(context.Context) (pbs.UpstreamMessageServiceClient, error)

UpstreamMessageServiceClientProducer produces a client and should be self-healing if an existing grpc connection closes.

func TestUpstreamService added in v0.13.0

TestUpstreamService starts a controller with a downstream worker, which are tore down at the end of the test.

Returns a UpstreamMessageServiceClientProducer for the worker, the worker's NodeInformation and the worker's KeyId.

type UpstreamMessageTypeSpecifier added in v0.13.0

type UpstreamMessageTypeSpecifier interface {
	// Encrypted returns true if the request/response should be encrypted
	Encrypted() bool

	// AllocRequest will allocate a type specific request proto message
	AllocRequest() proto.Message

	// AllocResponse will allocate a type specific response proto message
	AllocResponse() proto.Message
}

UpstreamMessageTypeSpecifier defines an interface for specifying type information for an UpstreamMessageRequest(s).

See handlers.SendUpstreamMessage for how this is used to send an UpstreamMessageRequest via registered upstream message type specifiers.

Jump to

Keyboard shortcuts

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