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)
Click to show internal directories.
Click to hide internal directories.