wire

package
v0.0.0-...-af321b4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidContext = errors.New("invalid context type")
View Source
var ErrProtocolError = errors.New("protocol error detected")
View Source
var ErrRemoteError = errors.New("remote error detected")
View Source
var ErrTooMuchData = errors.New("more data that expected passed in")
View Source
var ErrUnknownMethod = errors.New("unknown method requested")

Functions

func Now

func Now() *pb.Timestamp

func Recycle

func Recycle(v interface{})

Types

type ComposedConn

type ComposedConn struct {
	*bufio.Reader
	io.Writer
	io.Closer
	Recyclable
}

func (*ComposedConn) BufioReader

func (c *ComposedConn) BufioReader() *bufio.Reader

type Context

type Context interface {
	Account() *pb.Account
	ReadMarshal(v Unmarshaller) (byte, error)
	WriteMarshal(tag byte, v Marshaller) error

	// Forwards any data between the 2 contexts
	BridgeTo(other Context) error

	// Returns a writer that will send traffic as framed messages
	Writer() io.WriteCloser

	// Returns a reader that recieves traffic as framed messages
	Reader() io.Reader

	// Returns the total number of messages and bytes, respectively, that the
	// context has transmitted.
	Accounting() (int64, int64)

	// Close the context and cleanup any resources. Does not close
	// any IOs though.
	Close() error
}

func NewContext

func NewContext(accountId *pb.Account, fr *FramingReader, fw *FramingWriter) Context

func WithCloser

func WithCloser(c Context, closers ...func() error) Context

type FramingReader

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

func NewFramingReader

func NewFramingReader(r io.Reader) (*FramingReader, error)

func (*FramingReader) BufReader

func (f *FramingReader) BufReader() *bufio.Reader

func (*FramingReader) Next

func (f *FramingReader) Next() (byte, int, error)

func (*FramingReader) Read

func (f *FramingReader) Read(b []byte) (int, error)

func (*FramingReader) ReadAdapter

func (f *FramingReader) ReadAdapter() *ReadAdapter

func (*FramingReader) ReadMarshal

func (f *FramingReader) ReadMarshal(v Unmarshaller) (byte, int, error)

func (*FramingReader) Recycle

func (f *FramingReader) Recycle()

func (*FramingReader) RecylableBufReader

func (f *FramingReader) RecylableBufReader() io.Reader

type FramingWriter

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

func NewFramingWriter

func NewFramingWriter(w io.Writer) (*FramingWriter, error)

func (*FramingWriter) Recycle

func (f *FramingWriter) Recycle()

func (*FramingWriter) Write

func (f *FramingWriter) Write(b []byte) (int, error)

func (*FramingWriter) WriteAdapter

func (f *FramingWriter) WriteAdapter() *WriteAdapter

func (*FramingWriter) WriteFrame

func (f *FramingWriter) WriteFrame(tag byte, size int) error

func (*FramingWriter) WriteMarshal

func (f *FramingWriter) WriteMarshal(tag byte, v Marshaller) (int, error)

type MarshalBytes

type MarshalBytes []byte

func (*MarshalBytes) MarshalTo

func (m *MarshalBytes) MarshalTo(b []byte) (int, error)

func (*MarshalBytes) Size

func (m *MarshalBytes) Size() int

func (*MarshalBytes) Unmarshal

func (m *MarshalBytes) Unmarshal(b []byte) error

type Marshaller

type Marshaller interface {
	Size() int
	MarshalTo(b []byte) (int, error)
}

type RPCClient

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

func NewRPCClient

func NewRPCClient(stream *yamux.Stream) *RPCClient

func (*RPCClient) Begin

func (r *RPCClient) Begin(host, path string, req Marshaller) (RPCContext, error)

func (*RPCClient) Call

func (r *RPCClient) Call(host, path string, req Marshaller, resp Unmarshaller) error

type RPCContext

type RPCContext interface {
	Context
	ReadRequest(v Unmarshaller) error
	WriteResponse(v Marshaller) error
}

type RPCHandler

type RPCHandler interface {
	HandleRPC(ctx context.Context, wctx RPCContext) error
}

type RPCServer

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

func (*RPCServer) AddMethod

func (r *RPCServer) AddMethod(name string, h RPCHandler)

func (*RPCServer) HandleRequest

func (r *RPCServer) HandleRequest(ctx context.Context, L hclog.Logger, wctx Context, wreq *pb.Request) error

type ReadAdapter

type ReadAdapter struct {
	FR *FramingReader
	// contains filtered or unexported fields
}

func (*ReadAdapter) Read

func (f *ReadAdapter) Read(b []byte) (int, error)

type ReadMarshaler

type ReadMarshaler interface {
	ReadMarshal(Unmarshaller) (byte, int, error)
}

type Recyclable

type Recyclable interface {
	Recycle()
}

type ULID

type ULID struct {
	ulid.ULID
}

func ULIDFromBytes

func ULIDFromBytes(b []byte) ULID

func (ULID) Bytes

func (u ULID) Bytes() []byte

func (ULID) Compare

func (u ULID) Compare(other ULID) int

func (ULID) Equal

func (u ULID) Equal(other ULID) bool

func (ULID) Marshal

func (u ULID) Marshal() ([]byte, error)

func (ULID) MarshalJSON

func (u ULID) MarshalJSON() ([]byte, error)

func (ULID) MarshalTo

func (u ULID) MarshalTo(data []byte) (n int, err error)

func (*ULID) Size

func (u *ULID) Size() int

func (*ULID) Unmarshal

func (u *ULID) Unmarshal(data []byte) error

func (*ULID) UnmarshalJSON

func (u *ULID) UnmarshalJSON(data []byte) error

type Unmarshaller

type Unmarshaller interface {
	Unmarshal([]byte) error
}

type WriteAdapter

type WriteAdapter struct {
	FW *FramingWriter
}

func (*WriteAdapter) Close

func (f *WriteAdapter) Close() error

func (*WriteAdapter) Write

func (f *WriteAdapter) Write(b []byte) (int, error)

type WriteMarshaler

type WriteMarshaler interface {
	WriteMarshal(byte, Marshaller) (int, error)
}

Jump to

Keyboard shortcuts

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