rpc

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rpc implements OMG DDS-RPC style request-reply over a DDS participant. A Requester sends typed requests and receives correlated replies. A Replier receives requests and sends replies. Both use two topics internally: <base>/request and <base>/reply.

Wire format: every payload is prefixed with a 16-byte CorrelationID so that the Requester can match replies to outstanding requests without any broker-level correlation support.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoReply = fmt.Errorf("rpc: no reply received")

ErrNoReply is returned by Requester.Request when the context expires before a correlated reply arrives.

Functions

This section is empty.

Types

type CorrelationID

type CorrelationID [16]byte

CorrelationID is the 16-byte identifier embedded in every request and reply payload to match replies to outstanding requests.

type Replier

type Replier[Req, Rep any] struct {
	// contains filtered or unexported fields
}

Replier receives typed RPC requests and dispatches correlated replies. Create with NewReplier; call Close when done.

func NewReplier

func NewReplier[Req, Rep any](
	p dds.Participant,
	topic string,
	reqCodec dds.Codec[Req],
	repCodec dds.Codec[Rep],
	qos dds.QoS,
) (*Replier[Req, Rep], error)

NewReplier creates a Replier on the given participant. It listens on <topic>/request and replies on <topic>/reply.

func (*Replier[Req, Rep]) Close

func (rl *Replier[Req, Rep]) Close() error

Close stops the pump goroutine and releases DDS resources.

func (*Replier[Req, Rep]) Reply

func (rl *Replier[Req, Rep]) Reply(ctx context.Context, req Request[Req], rep Rep) error

Reply sends a reply correlated to req. ctx controls the write deadline.

func (*Replier[Req, Rep]) Requests

func (rl *Replier[Req, Rep]) Requests() <-chan Request[Req]

Requests returns the channel on which decoded RPC requests are delivered. Iterate with range or a select; close is handled by Close.

type Request

type Request[Req any] struct {
	ID    CorrelationID
	Value Req
}

Request is an inbound RPC request delivered on the Replier.Requests channel.

type Requester

type Requester[Req, Rep any] struct {
	// contains filtered or unexported fields
}

Requester sends typed RPC requests and waits for correlated replies. Create with NewRequester; call Close when done.

func NewRequester

func NewRequester[Req, Rep any](
	p dds.Participant,
	topic string,
	reqCodec dds.Codec[Req],
	repCodec dds.Codec[Rep],
	qos dds.QoS,
) (*Requester[Req, Rep], error)

NewRequester creates a Requester on the given participant. It publishes requests on <topic>/request and receives replies on <topic>/reply.

func (*Requester[Req, Rep]) Close

func (r *Requester[Req, Rep]) Close() error

Close shuts down the requester and releases DDS resources.

func (*Requester[Req, Rep]) Request

func (r *Requester[Req, Rep]) Request(ctx context.Context, req Req) (Rep, error)

Request sends req and blocks until a correlated reply arrives or ctx expires.

Jump to

Keyboard shortcuts

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