Documentation ¶
Index ¶
- Constants
- Variables
- func CallFunction(f interface{}, v ...interface{}) []reflect.Value
- func CallMethod(instance interface{}, method string, v ...interface{}) []reflect.Value
- func Future(f func() (interface{}, error)) func() (interface{}, error)
- func GO(v ...interface{})
- func GOFunction(ref IRef, v ...interface{})
- func GOFunctionWithWG(wg *sync.WaitGroup, ref IRef, v ...interface{})
- func GOMethod(ref IRef, instance interface{}, method string, v ...interface{})
- func GOMethodWithWG(wg *sync.WaitGroup, ref IRef, instance interface{}, method string, ...)
- func GetClassMethodName(s IClass) string
- func GetFunctionName() string
- type AppContext
- type CallObject
- type Callback
- type ICaller
- type IClass
- type IRef
- type Ref
- type Ret
Constants ¶
const ( // CallObejctType call object type CallObejctType = iota CallObejctNormal = 1 //普通模式 CallObejctNotify = 2 //通知模式,无响应 CallObejctTransport = 3 //透传模式,handler可以收到callobject )
const ( // ErrorCodeID id define ErrorCodeID = iota //nethopper 1000-2000 //ErrCodeModule ErrCodeModule = 1000 //ErrCodeWorker ErrCodeWorker = 1001 //ErrCodeProcessor ErrCodeProcessor = 1002 //ErrCodeRouter ErrCodeRouter = 1003 //ErrCodeLogic ErrCodeLogic = 1004 )
Variables ¶
var ErrCallTimeout = errors.New("Timeout on call")
var ErrQueueEmpty = errors.New("Queue is empty")
var ErrQueueFull = errors.New("Queue is full")
var ErrQueueIsClosed = errors.New("Queue is Closed")
ErrQueueIsClosed queue is closed
var ErrQueueTimeout = errors.New("Timeout on queue")
ErrQueueTimeout queue push or pop timeout
var ErrReadChanTimeout = errors.New("read channel timeout")
var ErrWriteChanTimeout = errors.New("write channel timeout")
var GCallObjectPool = sync.Pool{ New: func() interface{} { return &CallObject{ Timer: time.NewTimer(TimeoutChanTime), } }, }
var TimeoutChanTime = 8 * time.Second
Functions ¶
func CallFunction ¶
CallFunction simply to dynamically call a function or a method on an object Calls the callback given by the first parameter and passes the remaining parameters as arguments. Zero or more parameters to be passed to the callback. Returns the return value of the callback.
func CallMethod ¶
CallMethod simply to dynamically call a method on an object Calls the instance given by the first parameter and method name as the second parameter and passes the remaining parameters as arguments. Zero or more parameters to be passed to the method. Returns the return value of the method.
func GOFunction ¶
func GOFunction(ref IRef, v ...interface{})
GOFunction wapper exec goruntine and ref count
func GOFunctionWithWG ¶
GOFunctionWithWG wapper exec goruntine,waitgroup and ref count
func GOMethodWithWG ¶
func GOMethodWithWG(wg *sync.WaitGroup, ref IRef, instance interface{}, method string, v ...interface{})
GOMethodWithWG wapper exec goruntine,waitgroup and ref count
func GetClassMethodName ¶
GetClassMethodName 获取正在运行的class函数名
Types ¶
type AppContext ¶
func NewAppContext ¶
func NewAppContext() *AppContext
type CallObject ¶
type CallObject struct { Caller ICaller CmdID int32 Option int32 Type int8 Args []interface{} Trace []uint8 ChanRet chan *Ret Timer *time.Timer }
CallObject call struct
func NewCallObject ¶
func NewCallObject(caller ICaller, cmdID int32, opt int32, args ...interface{}) *CallObject
NewCallObject create call object
func NewNotifyObject ¶
func NewNotifyObject(caller ICaller, cmdID int32, opt int32, args ...interface{}) *CallObject
NewNotifyObject create notify object
func NewTransportObject ¶
func NewTransportObject(caller ICaller, cmdID int32, opt int32, args ...interface{}) *CallObject
NewTransportObject create transport object
func (*CallObject) Init ¶
func (c *CallObject) Init(t int8, caller ICaller, cmdID int32, opt int32, args ...interface{}) *CallObject
func (*CallObject) Reset ¶
func (c *CallObject) Reset() *CallObject
func (*CallObject) SetRet ¶
func (c *CallObject) SetRet(ret *Ret) bool
func (*CallObject) SetTrace ¶
func (c *CallObject) SetTrace(mid ...uint8)
type ICaller ¶
type ICaller interface {
Execute(obj *CallObject) *Ret
}