fastrpc

package module
v0.0.0-...-ef1d54d Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

fastrpc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(event Event, addr string) (err error)

Types

type Action

type Action int
const (
	None Action = iota
	Close
	Shutdown
)

type CompressType

type CompressType byte
const (
	CompressTypeGzip CompressType = iota
	CompressTypeSnappy
)

type Conn

type Conn interface {
	LocalAddr() net.Addr
	RemoteAddr() net.Addr
}

type Event

type Event struct {
	LoopNum int
	Open    func(c Conn) (out []byte, opts Options, action Action)
	Close   func(c Conn, err error) (action Action)
	Data    func(c Conn, in []byte) (out []byte, action Action)
	Serve   func(svr Server) (action Action)
}
type Header [11]byte // 0: magicNumber | 1:(0): heartbeat | 1:(1-3): payloadType | 1:(4-6): compressType | 1:(7): status | 2-9: uuid | 10:(0-3): bodyLength

type Option

type Option func(opts *Options)

type Options

type Options struct {
	KeepAliveSec int
}

func SetOption

func SetOption(options ...Option) *Options

type Package

type Package struct {
	*Header
	RpcPath   string
	RpcMethod string
	Payload   []byte
	Data      []byte
}

type PayloadType

type PayloadType byte
const (
	PayloadTypeJson PayloadType = iota
	PayloadTypeProtobuf
)

type Server

type Server struct {
	Addr    net.Addr
	LoopNum int
}

Directories

Path Synopsis
example
net/client command
net/server command

Jump to

Keyboard shortcuts

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