multicast

package
v0.0.0-...-c6e4f4a Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OKCode = 0
	OKMsg  = "ok"
)

Variables

View Source
var (
	ErrServerError       = NewError(10000, "server error")
	ErrInvalidConnection = NewError(10001, "invalid connection")
	ErrHandleTimeout     = NewError(10002, "handle timeout")
	ErrInvalidParams     = NewError(10003, "invalid params")
)
View Source
var (
	ErrUnknownCmd = errors.New("unknown command")
)

Functions

func NewSeqno

func NewSeqno() string

Types

type Body

type Body struct {
	Cmd   string      `json:"cmd"`
	Seqno string      `json:"seqno,omitempty"`
	Data  interface{} `json:"data,omitempty"`
}

type BytePool

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

func NewBytePool

func NewBytePool(n int) *BytePool

func (*BytePool) Get

func (p *BytePool) Get() []byte

func (*BytePool) Put

func (p *BytePool) Put(b []byte)

type Error

type Error struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func NewError

func NewError(code int, msg string) *Error

func (Error) Error

func (e Error) Error() string

type Group

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

func (*Group) Group

func (g *Group) Group(handlers ...Handler) *Group

func (*Group) OnCmd

func (g *Group) OnCmd(cmd string, handlers ...Handler)

type Handler

type Handler func(ctx *MessageContext)

func Log

func Log() Handler

func Recovery

func Recovery() Handler

func Timeout

func Timeout() Handler

type Message

type Message struct {
	N    int
	Src  *net.UDPAddr
	Byte []byte
}

type MessageBody

type MessageBody struct {
	Cmd   string          `json:"cmd"`
	Seqno string          `json:"seqno,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

type MessageContext

type MessageContext struct {
	Message *Message
	Body    *MessageBody
	Server  *Server
	Error   error
	// contains filtered or unexported fields
}

func (*MessageContext) Abort

func (c *MessageContext) Abort()

func (*MessageContext) AbortWithError

func (c *MessageContext) AbortWithError(err error)

func (*MessageContext) Context

func (c *MessageContext) Context() context.Context

func (*MessageContext) IsAborted

func (c *MessageContext) IsAborted() bool

func (*MessageContext) LogError

func (c *MessageContext) LogError(err error)

func (*MessageContext) Next

func (c *MessageContext) Next()

func (*MessageContext) ShouldBindJson

func (c *MessageContext) ShouldBindJson(v interface{}) error

func (*MessageContext) WithContext

func (c *MessageContext) WithContext(ctx context.Context) *MessageContext

type MessageContextPool

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

func NewMessageContextPool

func NewMessageContextPool() *MessageContextPool

func (*MessageContextPool) Get

func (*MessageContextPool) Put

type Server

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

func NewServer

func NewServer(wildcardIP string, groupIP string, port int, buffSize int) *Server

func (*Server) Group

func (s *Server) Group(handlers ...Handler) *Group

func (*Server) OnCmd

func (s *Server) OnCmd(cmd string, handlers ...Handler)

func (*Server) Send

func (s *Server) Send(b []byte) error

func (*Server) SendJson

func (s *Server) SendJson(v interface{}) error

func (*Server) SetLoopback

func (s *Server) SetLoopback(en bool)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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