workers

package
v0.0.0-...-15c1b16 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUniqueId

func GenerateUniqueId() string

Types

type GrpcBidiStreamServer

type GrpcBidiStreamServer[ServerMessage IdentifiableMessage, ClientMessage IdentifiableMessage] interface {
	Send(ServerMessage) error
	Recv() (ClientMessage, error)
	grpc.ServerStream
}

type IdentifiableMessage

type IdentifiableMessage interface {
	GetId() RequestIdentifier
}

IdentifiableMessage is a message that has an ID, used to match requests and responses

type RequestIdentifier

type RequestIdentifier = string

type WorkerRequestBroker

type WorkerRequestBroker[Request IdentifiableMessage, Response IdentifiableMessage] struct {
	// contains filtered or unexported fields
}

WorkerRequestBroker helps manage the async bidirectional stream between the worker (typically a client SDK) and the Nitric server.

the broker facilitates sending requests to a worker and awaits responses, then matches them with the corresponding request.
This enables users of this brokers to treat the request/response lifecycle with the worker as if they were synchronous.

func NewWorkerRequestBroker

func NewWorkerRequestBroker[Request IdentifiableMessage, Response IdentifiableMessage](workerConnectionStream GrpcBidiStreamServer[Request, Response]) *WorkerRequestBroker[Request, Response]

func (*WorkerRequestBroker[Request, Response]) Run

func (w *WorkerRequestBroker[Request, Response]) Run() error

Run the connection broker, allowing async communication with the worker (i.e.

func (*WorkerRequestBroker[Request, Response]) Send

func (w *WorkerRequestBroker[Request, Response]) Send(req Request) (*Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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