rpc

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallCmd

type CallCmd struct {
	Id      uint32
	Session uint32
	Args    []reflect.Value
}

func (*CallCmd) ReadFrom

func (c *CallCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*CallCmd) WriteTo

func (c *CallCmd) WriteTo(w io.Writer) (n int64, err error)

type Cmd

type Cmd = uint8
const (
	CmdPing   Cmd = 0x00
	CmdPong   Cmd = 0x01
	CmdDef    Cmd = 0x02
	CmdCall   Cmd = 0x03
	CmdReturn Cmd = 0x04
	CmdError  Cmd = 0x05
)

type Command

type Command interface {
	WriteTo(io.Writer) (int64, error)
	ReadFrom(io.Reader, *Point) (int64, error)
}

type CommandNewer

type CommandNewer = func() Command

type DefCmd

type DefCmd struct {
	Id   uint32
	Name string
}

func (*DefCmd) ReadFrom

func (c *DefCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*DefCmd) WriteTo

func (c *DefCmd) WriteTo(w io.Writer) (n int64, err error)

type Errid

type Errid = uint16
const (
	ErrString    Errid = 0x00
	ErrNotExists Errid = 0x01
	ErrArgs      Errid = 0x02
)

type ErrorCmd

type ErrorCmd struct {
	Session uint32
	Errid   Errid
	Msg     string
	Ptrs    []reflect.Value
}

func (*ErrorCmd) ReadFrom

func (c *ErrorCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*ErrorCmd) WriteTo

func (c *ErrorCmd) WriteTo(w io.Writer) (n int64, err error)

type PingCmd

type PingCmd struct {
	Data uint64
}

func (*PingCmd) ReadFrom

func (c *PingCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*PingCmd) WriteTo

func (c *PingCmd) WriteTo(w io.Writer) (n int64, err error)

type Point

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

func NewPoint

func NewPoint(w io.Writer, r io.ReadCloser) (p *Point)

func NewPointWithCtx

func NewPointWithCtx(w io.Writer, r io.ReadCloser, ctx context.Context) (p *Point)

func (*Point) Call

func (p *Point) Call(name string, args ...any) (res any, err error)

func (*Point) Close

func (p *Point) Close() (err error)

func (*Point) DefineCmd

func (p *Point) DefineCmd(id Cmd, newer CommandNewer)

func (*Point) Listen

func (p *Point) Listen()

func (*Point) ListenAndWait

func (p *Point) ListenAndWait() (err error)

func (*Point) Ping

func (p *Point) Ping() (err error)

func (*Point) Register

func (p *Point) Register(name string, fuc any) (err error)

func (*Point) SendCommand

func (p *Point) SendCommand(id Cmd, cmd Command) (err error)

func (*Point) Wait

func (p *Point) Wait() (err error)

type PongCmd

type PongCmd struct {
	Data uint64
}

func (*PongCmd) ReadFrom

func (c *PongCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*PongCmd) WriteTo

func (c *PongCmd) WriteTo(w io.Writer) (n int64, err error)

type RemoteErr

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

func (*RemoteErr) Error

func (e *RemoteErr) Error() string

type ReturnCmd

type ReturnCmd struct {
	Session uint32
	Res     reflect.Value
	Ptrs    []reflect.Value
}

func (*ReturnCmd) ReadFrom

func (c *ReturnCmd) ReadFrom(r io.Reader, p *Point) (n int64, err error)

func (*ReturnCmd) WriteTo

func (c *ReturnCmd) WriteTo(w io.Writer) (n int64, err error)

Directories

Path Synopsis
_example

Jump to

Keyboard shortcuts

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