workers

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleStream added in v1.1.1

func HandleStream[ClientMessage any, RegistrationResponse any, ServerMessage StdServerMsg[RegistrationResponse]](
	ctx context.Context,
	createStream func(ctx context.Context) (Stream[ClientMessage, RegistrationResponse, ServerMessage], error),
	initReq *ClientMessage,
	handleServerMsg func(msg ServerMessage) (*ClientMessage, error),
) error

HandleStream runs a nitric worker, in the standard request/response pattern. No changes needed here other than the updated types in the signature.

Types

type Manager

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

func GetDefaultManager

func GetDefaultManager() *Manager

func New

func New() *Manager

New is used to create the top level resource manager. Note: this is not required if you are using resources.NewApi() and the like. These use a default manager instance.

func (*Manager) AddWorker

func (m *Manager) AddWorker(name string, s StreamWorker)

func (*Manager) RegisterPolicy

func (m *Manager) RegisterPolicy(res *v1.ResourceIdentifier, actions ...v1.Action) error

func (*Manager) RegisterResource

func (m *Manager) RegisterResource(request *v1.ResourceDeclareRequest) <-chan RegisterResult

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

type RegisterResult

type RegisterResult struct {
	Identifier *v1.ResourceIdentifier
	Err        error
}

type StdServerMsg added in v1.1.1

type StdServerMsg[RegistrationResponse any] interface {
	GetRegistrationResponse() *RegistrationResponse
}

type Stream added in v1.1.1

type Stream[ClientMessage any, RegistrationResponse any, ServerMessage StdServerMsg[RegistrationResponse]] interface {
	Send(*ClientMessage) error
	Recv() (ServerMessage, error)
	grpc.ClientStream
}

type StreamWorker

type StreamWorker interface {
	Start(context.Context) error
}

Jump to

Keyboard shortcuts

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