envoy

package module
v0.0.0-...-9bd7cc4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

envoy

A lightweight, fast, and generic bidirectional RPC framework

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timeout reached")
View Source
var ErrUvarintCorrupted = errors.New("failed to read uvarint is corrupted")

Functions

func SetLogger

func SetLogger(newLogger zerolog.Logger)

Types

type Buffer

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

func NewBuffer

func NewBuffer(length int) *Buffer

func NewBufferFrom

func NewBufferFrom(dat []byte) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Retursn all of the bytes in the buffer

func (*Buffer) ReadUint8

func (b *Buffer) ReadUint8() uint8

func (*Buffer) ReadUint32

func (b *Buffer) ReadUint32() (uint32, error)

func (*Buffer) ReadUint64

func (b *Buffer) ReadUint64() (uint64, error)

func (*Buffer) Reset

func (b *Buffer) Reset()

func (*Buffer) WriteUint8

func (b *Buffer) WriteUint8(v uint8) *Buffer

func (*Buffer) WriteUint32

func (b *Buffer) WriteUint32(v uint32) *Buffer

type Client

type Client[S, C any] struct {
	Handler S
	Call    C
	// contains filtered or unexported fields
}

func (*Client[S, C]) Close

func (c *Client[S, C]) Close() error

func (*Client[S, C]) Closed

func (c *Client[S, C]) Closed() bool

TODO - get rid of this

func (*Client[S, C]) Connect

func (c *Client[S, C]) Connect(sock net.Socket)

func (*Client[S, C]) ReadEgress

func (c *Client[S, C]) ReadEgress() int64

func (*Client[S, C]) ReadIngress

func (c *Client[S, C]) ReadIngress() int64

type Config

type Config struct {
	MaxRecvPacketSize int  // Default 65K
	CloseOnInvalid    bool // Close the socket on a message that is too big or doesn't decode, instead of dropping it. For peers that we never trust, ie players
}

type HandlerFunc

type HandlerFunc func(req any) any

type InterfaceDef

type InterfaceDef[S, C any] struct {
	Service S
	Client  C
	// contains filtered or unexported fields
}

Interface Definition

func NewInterfaceDef

func NewInterfaceDef[S, C any]() InterfaceDef[S, C]

func (InterfaceDef[S, C]) NewClient

func (d InterfaceDef[S, C]) NewClient(config *Config) *Client[C, S]

Returns the client side of the interface

func (InterfaceDef[S, C]) NewServer

func (d InterfaceDef[S, C]) NewServer(config *Config) *Client[S, C]

Returns the server side of the interface

type Message

type Message struct {
	Data []byte
}

type MessageHandlerFunc

type MessageHandlerFunc func(req any)

type MsgDef

type MsgDef[A any] struct {
	// contains filtered or unexported fields
}

Message Definition

func (MsgDef[A]) Handler

func (d MsgDef[A]) Handler() (reflect.Type, MessageHandlerFunc)

func (MsgDef[A]) MsgType

func (d MsgDef[A]) MsgType() any

func (*MsgDef[A]) Register

func (d *MsgDef[A]) Register(handler func(A))

func (MsgDef[A]) Send

func (d MsgDef[A]) Send(msg A) error

func (MsgDef[A]) SendGetSize

func (d MsgDef[A]) SendGetSize(msg A) (int, error)

Sends the message and returns the number of bytes sent

type MsgDefinition

type MsgDefinition interface {
	MsgType() any
}

type MsgHandler

type MsgHandler interface {
	Handler() (reflect.Type, MessageHandlerFunc)
}

type NewDecoder

type NewDecoder interface {
	DecodeCod([]byte) (int, error)
}

type NewEncoder

type NewEncoder interface {
	EncodeCod([]byte) []byte
}

type Request

type Request struct {
	Id   uint32 // Tracks the request Id
	Data []byte
}

Internal messages

type Response

type Response struct {
	Id   uint32 // Tracks the request Id
	Data []byte
}

type RpcDef

type RpcDef[Req, Resp any] struct {
	// contains filtered or unexported fields
}

RPC Definition

func (RpcDef[Req, Resp]) Call

func (d RpcDef[Req, Resp]) Call(req Req) (Resp, error)

func (RpcDef[Req, Resp]) CallTimeout

func (d RpcDef[Req, Resp]) CallTimeout(req Req, timeout time.Duration) (Resp, error)

func (RpcDef[Req, Resp]) Handler

func (d RpcDef[Req, Resp]) Handler() (reflect.Type, registeredRpc)

func (*RpcDef[Req, Resp]) Register

func (d *RpcDef[Req, Resp]) Register(handler func(Req) Resp)

func (*RpcDef[Req, Resp]) RegisterAsync

func (d *RpcDef[Req, Resp]) RegisterAsync(handler func(Req) Resp)

Like Register, but each request is handled on its own goroutine, so a slow handler doesn't block the connection from reading Warning: The handler can run concurrently with itself and with every other handler on the connection. It loses its ordering with everything else that is received

func (RpcDef[Req, Resp]) ReqType

func (d RpcDef[Req, Resp]) ReqType() any

func (RpcDef[Req, Resp]) RespType

func (d RpcDef[Req, Resp]) RespType() any

type RpcDefinition

type RpcDefinition interface {
	ReqType() any
	RespType() any
}

type RpcHandler

type RpcHandler interface {
	Handler() (reflect.Type, registeredRpc)
}

type UnionBuilder

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

func NewUnion

func NewUnion(structs ...any) *UnionBuilder

func (*UnionBuilder) Deserialize

func (u *UnionBuilder) Deserialize(buf *Buffer) (any, error)

func (*UnionBuilder) Serialize

func (u *UnionBuilder) Serialize(buf *Buffer, val any) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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