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) 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 ¶
NewCodecWithRelay initiates new server rpc codec with a relay of choice.
func (*Codec) ReadRequestBody ¶
ReadRequestBody fetches prefixed body data and automatically unmarshal it as json. RawBody flag will populate []byte lice argument for rpc method.
func (*Codec) ReadRequestHeader ¶
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