gn

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 17 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReTokenBase uint64 = 1
)

Functions

func ParseCommands

func ParseCommands()

Types

type App

type App struct {
	RRoutineCan   context.CancelFunc
	WRoutineCan   context.CancelFunc
	APIRoutineCan context.CancelFunc
	RPCRoutineCan context.CancelFunc
	// contains filtered or unexported fields
}

func (*App) APIRouter

func (a *App) APIRouter(router string, newGoRoutine bool, handlerFunc ...HandlerFunc)

func (*App) AddConfigFile

func (a *App) AddConfigFile(keyName, path, configType string) error

func (*App) AddExceptionHandler

func (a *App) AddExceptionHandler(handler gnError.ExceptionHandleFunc)

func (*App) BoadCastByGroupName

func (a *App) BoadCastByGroupName(groupName string, data []byte)

func (*App) CMDHandler

func (a *App) CMDHandler(cmd string, handler HandlerFunc)

func (*App) DelGroup

func (a *App) DelGroup(groupName string)

func (*App) DelObjectByTag

func (a *App) DelObjectByTag(tag string)

func (*App) Done

func (a *App) Done()

func (*App) ErrorToConnector

func (a *App) ErrorToConnector(session *Session, code string, errorMsg string)

func (*App) GetConfigViper

func (a *App) GetConfigViper(keyName string) *viper.Viper

func (*App) GetGroup

func (a *App) GetGroup(groupName string) (*Group, bool)

func (*App) GetLinker

func (a *App) GetLinker() linker.ILinker

func (*App) GetObjectByTag

func (a *App) GetObjectByTag(tag string) (interface{}, bool)

func (*App) GetRunRoutineNum

func (a *App) GetRunRoutineNum() int

func (*App) GetServerConfig

func (a *App) GetServerConfig() *config.Config

func (*App) NewGroup

func (a *App) NewGroup(groupName string) *Group

func (*App) NotifyRPCJsonMsg

func (a *App) NotifyRPCJsonMsg(serverId string, handlerName string, obj interface{}) error

func (*App) NotifyRPCMsg

func (a *App) NotifyRPCMsg(serverId string, handlerName string, data []byte) error

func (*App) NotifyRPCProtoBufMsg

func (a *App) NotifyRPCProtoBufMsg(serverId string, handlerName string, obj interface{}) error

func (*App) PushJsonMsg

func (a *App) PushJsonMsg(session *Session, obj interface{})

func (*App) PushMsg

func (a *App) PushMsg(session *Session, data []byte)

func (*App) PushProtoBufMsg

func (a *App) PushProtoBufMsg(session *Session, obj interface{})

func (*App) RPCRouter

func (a *App) RPCRouter(router string, newGoRoutine bool, handlerFunc HandlerFunc)

func (*App) RequestRPCJsonMsg

func (a *App) RequestRPCJsonMsg(serverId string, handlerName string, obj interface{}) (IPack, error)

func (*App) RequestRPCMsg

func (a *App) RequestRPCMsg(serverId string, handlerName string, data []byte) (IPack, error)

func (*App) RequestRPCProtoBufMsg

func (a *App) RequestRPCProtoBufMsg(serverId string, handlerName string, obj interface{}) (IPack, error)

func (*App) Run

func (a *App) Run() error

func (*App) SetObjectByTag

func (a *App) SetObjectByTag(tag string, obj interface{})

func (*App) UseMiddleWare

func (a *App) UseMiddleWare(middleWare ...GNMiddleWare)

type AppCmd

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

func (*AppCmd) AddCmdHandler

func (ap *AppCmd) AddCmdHandler(cmd string, handler HandlerFunc)

func (*AppCmd) Done

func (ap *AppCmd) Done()

func (*AppCmd) LoopCmdInChan

func (ap *AppCmd) LoopCmdInChan(ctx context.Context)

func (*AppCmd) MemHandler

func (ap *AppCmd) MemHandler(pack IPack)

func (*AppCmd) PingHandler

func (ap *AppCmd) PingHandler(pack IPack)

func (*AppCmd) ReceiveCmdPack

func (ap *AppCmd) ReceiveCmdPack(pack IPack)

func (*AppCmd) Run

func (ap *AppCmd) Run() error

type ChanMsgPacket

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

多goroutine 通道同喜 封装 channel 传输用

type GNMiddleWare

type GNMiddleWare interface {
	Before(IPack)
	After(IPack)
}

type Group

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

group

func NewGroup

func NewGroup(app IApp, groupName string) *Group

func (*Group) AddSession

func (g *Group) AddSession(key string, s *Session)

func (*Group) BroadCast

func (g *Group) BroadCast(bytes []byte)

func (*Group) BroadCastJson

func (g *Group) BroadCastJson(obj interface{})

func (*Group) BroadCastProtoBuf

func (g *Group) BroadCastProtoBuf(obj interface{})

func (*Group) DelSession

func (g *Group) DelSession(key string)

func (*Group) GetSession

func (g *Group) GetSession(key string) (*Session, bool)

type H

type H map[string]interface{}

H is a shortcut for map[string]interface{}

type Handler

type Handler struct {
	Funcs      []HandlerFunc
	NewRoutine bool
}

handler router 注册

type HandlerFunc

type HandlerFunc func(IPack)

type IApp

type IApp interface {
	PushMsg(session *Session, data []byte)
	PushJsonMsg(session *Session, obj interface{})
	PushProtoBufMsg(session *Session, obj interface{})

	NotifyRPCMsg(serverId string, handlerName string, data []byte) error
	NotifyRPCJsonMsg(serverId string, handlerName string, obj interface{}) error
	NotifyRPCProtoBufMsg(serverId string, handlerName string, obj interface{}) error
	RequestRPCMsg(serverId string, handlerName string, data []byte) (IPack, error)
	RequestRPCJsonMsg(serverId string, handlerName string, obj interface{}) (IPack, error)
	RequestRPCProtoBufMsg(serverId string, handlerName string, obj interface{}) (IPack, error)

	APIRouter(router string, newGoRoutine bool, handlerFunc ...HandlerFunc)
	RPCRouter(router string, newGoRoutine bool, handlerFunc HandlerFunc)

	CMDHandler(cmd string, handler HandlerFunc)

	NewGroup(groupName string) *Group
	GetGroup(groupName string) (*Group, bool)
	BoadCastByGroupName(groupName string, data []byte)
	DelGroup(groupName string)

	SetObjectByTag(tag string, obj interface{})
	GetObjectByTag(tag string) (interface{}, bool)
	DelObjectByTag(tag string)

	Done()
	GetServerConfig() *config.Config
	Run() error

	AddExceptionHandler(handler gnError.ExceptionHandleFunc)
	GetLinker() linker.ILinker
	GetRunRoutineNum() int
	AddConfigFile(keyName, path, configType string) error
	GetConfigViper(keyName string) *viper.Viper
	UseMiddleWare(middleWare ...GNMiddleWare)
	// contains filtered or unexported methods
}

IApp

func DefaultApp

func DefaultApp(conf *config.Config) (IApp, error)

type IAppCmd

type IAppCmd interface {
	Run() error
	ReceiveCmdPack(pack IPack)
	AddCmdHandler(cmd string, handler HandlerFunc)
	Done()
}

func NewAppCmd

func NewAppCmd(nlinks linker.ILinker, detect *gnError.GnExceptionDetect) IAppCmd

type IPack

type IPack interface {
	Abort()
	IsAbort() bool
	GetAPP() IApp
	GetData() []byte
	SetHandlersTranferObj(decodOjb interface{})
	GetHandlersTranferObj() interface{}
	GetSession() *Session
	GetRouter() string
	ResultJson(obj interface{})
	ExceptionAbortJson(code, msg string)
	ResultProtoBuf(obj interface{})
	ResultBytes(bytes []byte)
	GetResults() []byte
	GetReplyToken() string
	GetDstSubRouter() string
	GetSrcSubRouter() string
	GetBindId() string
	SetRPCRespCode(code int)
	GetRPCRespCode() int32
	GetContextValue(key string) interface{}
	SetContextValue(key string, value interface{})
}

pack interface

func NewPack

func NewPack(a IApp, ts *config.TSession, session *Session) IPack

pack

type Pack

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

pack

func (*Pack) Abort

func (p *Pack) Abort()

func (*Pack) ExceptionAbortJson

func (p *Pack) ExceptionAbortJson(code, msg string)

func (*Pack) GetAPP

func (p *Pack) GetAPP() IApp

func (*Pack) GetBindId

func (p *Pack) GetBindId() string

func (*Pack) GetContextValue

func (p *Pack) GetContextValue(key string) interface{}

func (*Pack) GetData

func (p *Pack) GetData() []byte

func (*Pack) GetDstSubRouter

func (p *Pack) GetDstSubRouter() string

func (*Pack) GetHandlersTranferObj

func (p *Pack) GetHandlersTranferObj() interface{}

func (*Pack) GetRPCRespCode

func (p *Pack) GetRPCRespCode() int32

func (*Pack) GetReplyToken

func (p *Pack) GetReplyToken() string

func (*Pack) GetResults

func (p *Pack) GetResults() []byte

func (*Pack) GetRouter

func (p *Pack) GetRouter() string

func (*Pack) GetSession

func (p *Pack) GetSession() *Session

func (*Pack) GetSrcSubRouter

func (p *Pack) GetSrcSubRouter() string

func (*Pack) IsAbort

func (p *Pack) IsAbort() bool

func (*Pack) ResultBytes

func (p *Pack) ResultBytes(bytes []byte)

func (*Pack) ResultJson

func (p *Pack) ResultJson(obj interface{})

func (*Pack) ResultProtoBuf

func (p *Pack) ResultProtoBuf(obj interface{})

func (*Pack) SetContextValue

func (p *Pack) SetContextValue(key string, value interface{})

func (*Pack) SetHandlersTranferObj

func (p *Pack) SetHandlersTranferObj(decodOjb interface{})

func (*Pack) SetRPCRespCode

func (p *Pack) SetRPCRespCode(code int)

type Session

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

func NewSession

func NewSession(cid, scrNodeId, bindId string) *Session

func (*Session) BindId

func (s *Session) BindId(id string)

func (*Session) GetBindId

func (s *Session) GetBindId() string

func (*Session) GetCid

func (s *Session) GetCid() string

func (*Session) GetSrcSubRouter

func (s *Session) GetSrcSubRouter() string

Jump to

Keyboard shortcuts

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