vrpc

package
v0.0.0-...-ae07272 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 7 Imported by: 6

Documentation

Overview

Package vrpc provides support for automatically logging RPC Calls from a RPC Client to a RPC Server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(c *RPCServerCodec, payload interface{})

Encode is a convience function which writes to the wire and handels RPC errors

func NewClient

func NewClient(conn io.ReadWriteCloser, logger *govec.GoLog, options govec.GoLogOptions) *rpc.Client

NewClient returs an rpc.Client insturmented with vector clocks.

func RPCDial

func RPCDial(network, address string, logger *govec.GoLog, options govec.GoLogOptions) (*rpc.Client, error)

RPCDial connects to a RPC server at the specified network address. The logger is provided to be used by the RPCClientCodec for message capture.

func ServeRPCConn

func ServeRPCConn(server *rpc.Server, l net.Listener, logger *govec.GoLog, options govec.GoLogOptions)

ServeRPCConn is a convenience function that accepts connections for a given listener and starts a new goroutine for the server to serve a new connection. The logger is provided to be used by the RPCServerCodec for message capture.

Types

type RPCClientCodec

type RPCClientCodec struct {
	C       io.Closer
	Dec     *gob.Decoder
	Enc     *gob.Encoder
	EncBuf  *bufio.Writer
	Logger  *govec.GoLog
	Options govec.GoLogOptions
}

RPCClientCodec is an extension of the default rpc codec which uses a logger of type GoLog to capture all the calls to a RPC Server as well as responses from a RPC server.

func (*RPCClientCodec) Close

func (c *RPCClientCodec) Close() error

Close closes an RPCClientCodecs internal TCP connection

func (*RPCClientCodec) ReadResponseBody

func (c *RPCClientCodec) ReadResponseBody(body interface{}) (err error)

ReadResponseBody decodes a response body and updates it's local vector clock with that of the server.

func (*RPCClientCodec) ReadResponseHeader

func (c *RPCClientCodec) ReadResponseHeader(resp *rpc.Response) error

ReadResponseHeader deacodes an RPC response header on the client

func (*RPCClientCodec) WriteRequest

func (c *RPCClientCodec) WriteRequest(req *rpc.Request, param interface{}) (err error)

WriteRequest marshalls and sends an rpc request, and it's associated parameters to an RPC server

type RPCServerCodec

type RPCServerCodec struct {
	Rwc     io.ReadWriteCloser
	Dec     *gob.Decoder
	Enc     *gob.Encoder
	EncBuf  *bufio.Writer
	Logger  *govec.GoLog
	Options govec.GoLogOptions
	Closed  bool
}

RPCServerCodec is an extension of the default rpc codec which uses a logger of type of GoLog to capture all the requests made from the client to a RPC server as well as the server's to the clients.

func (*RPCServerCodec) Close

func (c *RPCServerCodec) Close() error

Close ends the underlying server TCP session

func (*RPCServerCodec) ReadRequestBody

func (c *RPCServerCodec) ReadRequestBody(body interface{}) (err error)

ReadRequestBody decodes a clinet request and updates the servers local vector clock with the clients values

func (*RPCServerCodec) ReadRequestHeader

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

ReadRequestHeader decodes a server rpc request header

func (*RPCServerCodec) WriteResponse

func (c *RPCServerCodec) WriteResponse(r *rpc.Response, body interface{}) (err error)

WriteResponse sends an rpc response, and it's associated result back to the client

Jump to

Keyboard shortcuts

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