rpc

package
v4.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rpc provides net/rpc codec implementations that use the goridge frame protocol as a transport.

Codec is a server-side codec (implements rpc.ServerCodec) and ClientCodec is the corresponding client-side codec (implements rpc.ClientCodec). Both support multiple serialization formats selected per-call via frame flags: Proto (protobuf), JSON, Gob, and Raw byte slices.

Frames and byte buffers are managed through sync.Pool to reduce allocations on the hot path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCodec

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

ClientCodec is codec for goridge connection.

func NewClientCodec

func NewClientCodec(rwc io.ReadWriteCloser) *ClientCodec

NewClientCodec initiates new server rpc codec over socket connection.

func (*ClientCodec) Close

func (c *ClientCodec) Close() error

Close closes the client connection.

func (*ClientCodec) ReadResponseBody

func (c *ClientCodec) ReadResponseBody(out any) error

ReadResponseBody response from the connection.

func (*ClientCodec) ReadResponseHeader

func (c *ClientCodec) ReadResponseHeader(r *rpc.Response) error

ReadResponseHeader reads response from the connection.

func (*ClientCodec) WriteRequest

func (c *ClientCodec) WriteRequest(r *rpc.Request, body any) error

WriteRequest writes request to the connection. Sequential.

type Codec

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

Codec represent net/rpc bridge over Goridge socket relay.

func NewCodec

func NewCodec(rwc io.ReadWriteCloser) *Codec

NewCodec initiates new server rpc codec over socket connection.

func NewCodecWithRelay

func NewCodecWithRelay(relay relay.Relay) *Codec

NewCodecWithRelay initiates new server rpc codec with a relay of choice.

func (*Codec) Close

func (c *Codec) Close() error

Close underlying socket.

func (*Codec) ReadRequestBody

func (c *Codec) ReadRequestBody(out any) error

ReadRequestBody fetches prefixed body data and automatically unmarshal it as json. RawBody flag will populate []byte lice argument for rpc method.

func (*Codec) ReadRequestHeader

func (c *Codec) ReadRequestHeader(r *rpc.Request) error

ReadRequestHeader receives frame with options options should have 2 values [0] - integer, sequence ID [1] - integer, offset for method name For example: 15Test.Payload SEQ_ID: 15 METHOD_LEN: 12 and we take 12 bytes from the payload as method name

func (*Codec) WriteResponse

func (c *Codec) WriteResponse(r *rpc.Response, body any) error

WriteResponse marshals response, byte slice or error to remote.

Jump to

Keyboard shortcuts

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