bzgrpc

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MsgIDErrorResponse = 0
View Source
const MsgIDNoResponse = 10000

Variables

This section is empty.

Functions

func ErrorResponse

func ErrorResponse(err error) (uint32, []byte, error)

func FSM

func FSM() *bzgncmap.Map[string, *IPState]

func New

func New[SI any, NI any](
	address string,
	routerMap RouterMap, fs map[uint32]NoticeFunc[NI],
	hearBeatTicker time.Duration, hearBeatTimeout time.Duration, isClientHearBeat bool,
	info SI,
) error

New 服务 SI server info 服务附带的信息 NC notice channel 通知的主结构 NI notice info 通知附带的信息

func NoResponse

func NoResponse() (uint32, []byte, error)

func Response

func Response(msgID uint32, data []byte) (uint32, []byte, error)

Types

type BizLog

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

func WrapLog

func WrapLog(logger *bzzap.Log, typ string) *BizLog

func (*BizLog) Debug

func (l *BizLog) Debug(msg string, err error)

func (*BizLog) Error

func (l *BizLog) Error(msg string, err error)

func (*BizLog) Fatal

func (l *BizLog) Fatal(msg string, err error)

func (*BizLog) Info

func (l *BizLog) Info(msg string, err error)

func (*BizLog) Panic

func (l *BizLog) Panic(msg string, err error)

func (*BizLog) Warn

func (l *BizLog) Warn(msg string, err error)

type IPState

type IPState struct {
	EndTime  int64 // 过期时间戳
	IP       string
	RespChan chan *protofile.LogicResponse
	Cancel   context.CancelFunc
	//IsNotFirst bool
	Info       any
	WriteTimer int64
}

type NoticeFunc

type NoticeFunc[I any] func(ctx context.Context, msgID uint32, info *NoticeInfo[I])

type NoticeInfo

type NoticeInfo[I any] struct {
	IP      string
	Info    I
	ResChan chan *protofile2.LogicResponse
	// contains filtered or unexported fields
}

func (*NoticeInfo[I]) NoticeSend

func (n *NoticeInfo[I]) NoticeSend(done bool, f func())

NoticeSend 自定义通知业务内调用的方法

type RouterMap

type RouterMap map[uint32]func(context.Context, []byte) (uint32, []byte, error)

RouterMap 路由 @return uint32 MsgID @return []byte 传输的原始数据 @return error 错误信息

type Service

type Service[SI any, NI any] struct {
	protofile2.UnimplementedLogicServiceServer
	// contains filtered or unexported fields
}

func (*Service[SI, NI]) Notice

func (s *Service[SI, NI]) Notice(ctx context.Context, ip string, info NI)

Notice 启动通知任务

func (*Service[SI, NI]) Send

func (s *Service[SI, NI]) Send(ss protofile2.LogicService_SendServer) error

func (*Service[SI, NI]) SendNotice

func (s *Service[SI, NI]) SendNotice(ctx context.Context, ip string, ss protofile2.LogicService_SendServer) error

SendNotice 发送通知任务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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