Documentation
¶
Index ¶
- Constants
- Variables
- type BaseCallable
- func (this *BaseCallable) Call(timeout time.Duration, name string, mids ...MiddlewareFunc) error
- func (this *BaseCallable) Call0(timeout time.Duration, name string, headers RpcMsgHeader, ...) (ackHeader RpcMsgHeader, err error)
- func (this *BaseCallable) Call1(timeout time.Duration, name string, in interface{}, mids ...MiddlewareFunc) error
- func (this *BaseCallable) Call2(timeout time.Duration, name string, headers RpcMsgHeader, in interface{}, ...) (ackHeader RpcMsgHeader, err error)
- func (this *BaseCallable) Call3(timeout time.Duration, name string, out interface{}, mids ...MiddlewareFunc) error
- func (this *BaseCallable) Call4(timeout time.Duration, name string, headers RpcMsgHeader, out interface{}, ...) (ackHeader RpcMsgHeader, err error)
- func (this *BaseCallable) Call5(timeout time.Duration, name string, in, out interface{}, ...) error
- func (this *BaseCallable) Call6(timeout time.Duration, name string, headers RpcMsgHeader, in, out interface{}, ...) (ackHeader RpcMsgHeader, err error)
- func (this *BaseCallable) Close() error
- func (this *BaseCallable) Len() int
- func (this *BaseCallable) Perform(timeout time.Duration, c Context)
- func (this *BaseCallable) Start()
- func (this *BaseCallable) Use(m ...MiddlewareFunc)
- func (this *BaseCallable) Writer() Writer
- type Callable
- type CallableCallback
- type CallableCallbacks
- type Context
- type Core
- type FuncDesc
- type HandleFunc
- type MiddlewareFunc
- type MsgType
- type RawMsg
- type RpcMsgHeader
- type SignalCallable
- type TimeWheelEntryImpl
- type VirtualCallable
- type Writer
- type WriterCloser
Constants ¶
View Source
const RpcLoopDefaultBufferSize = 1024 * 1024 * 4
Variables ¶
View Source
var Debug = true
View Source
var ErrNeedMore = errors.New("codec want read more bytes")
Functions ¶
This section is empty.
Types ¶
type BaseCallable ¶
type BaseCallable struct {
CallableCallbacks
liblpc.BaseUserData
TimeWheelEntryImpl
// contains filtered or unexported fields
}
func NewBaseCallable ¶
func NewBaseCallable(core Core, writer WriterCloser, driven Callable) *BaseCallable
func (*BaseCallable) Call ¶
func (this *BaseCallable) Call(timeout time.Duration, name string, mids ...MiddlewareFunc) error
func (*BaseCallable) Call0 ¶
func (this *BaseCallable) Call0(timeout time.Duration, name string, headers RpcMsgHeader, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
func (*BaseCallable) Call1 ¶
func (this *BaseCallable) Call1(timeout time.Duration, name string, in interface{}, mids ...MiddlewareFunc) error
func (*BaseCallable) Call2 ¶
func (this *BaseCallable) Call2(timeout time.Duration, name string, headers RpcMsgHeader, in interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
func (*BaseCallable) Call3 ¶
func (this *BaseCallable) Call3(timeout time.Duration, name string, out interface{}, mids ...MiddlewareFunc) error
func (*BaseCallable) Call4 ¶
func (this *BaseCallable) Call4(timeout time.Duration, name string, headers RpcMsgHeader, out interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
func (*BaseCallable) Call5 ¶
func (this *BaseCallable) Call5(timeout time.Duration, name string, in, out interface{}, mids ...MiddlewareFunc) error
func (*BaseCallable) Call6 ¶
func (this *BaseCallable) Call6(timeout time.Duration, name string, headers RpcMsgHeader, in, out interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
func (*BaseCallable) Close ¶
func (this *BaseCallable) Close() error
func (*BaseCallable) Start ¶
func (this *BaseCallable) Start()
func (*BaseCallable) Use ¶
func (this *BaseCallable) Use(m ...MiddlewareFunc)
func (*BaseCallable) Writer ¶
func (this *BaseCallable) Writer() Writer
type Callable ¶
type Callable interface {
liblpc.UserDataStorage
Start()
Call(timeout time.Duration, name string, mids ...MiddlewareFunc) error
Call0(timeout time.Duration, name string, headers RpcMsgHeader, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
Call1(timeout time.Duration, name string, in interface{}, mids ...MiddlewareFunc) error
Call2(timeout time.Duration, name string, headers RpcMsgHeader, in interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
Call3(timeout time.Duration, name string, out interface{}, mids ...MiddlewareFunc) error
Call4(timeout time.Duration, name string, headers RpcMsgHeader, out interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
Call5(timeout time.Duration, name string, in, out interface{}, mids ...MiddlewareFunc) error
Call6(timeout time.Duration, name string, headers RpcMsgHeader, in, out interface{}, mids ...MiddlewareFunc) (ackHeader RpcMsgHeader, err error)
Perform(timeout time.Duration, ctx Context)
SetOnReady(cb CallableCallback)
SetOnClose(cb CallableCallback)
liblpc.BucketEntry
BindTimeWheel(timeWheel *liblpc.TimeWheel)
NotifyTimeWheel()
Writer() Writer
}
func NewClientStreamCallable ¶
func NewClientStreamCallable(core Core, addr *liblpc.SyscallSockAddr, userData interface{}, m ...MiddlewareFunc) (Callable, error)
func NewConnStreamCallable ¶
func NewConnStreamCallable(core Core, fd int, userData interface{}, m ...MiddlewareFunc) Callable
type CallableCallback ¶
type CallableCallbacks ¶
type CallableCallbacks struct {
// contains filtered or unexported fields
}
func (*CallableCallbacks) DoClosed ¶
func (this *CallableCallbacks) DoClosed(err error)
func (*CallableCallbacks) DoReady ¶
func (this *CallableCallbacks) DoReady(err error)
func (*CallableCallbacks) SetOnClose ¶
func (this *CallableCallbacks) SetOnClose(cb CallableCallback)
func (*CallableCallbacks) SetOnReady ¶
func (this *CallableCallbacks) SetOnReady(cb CallableCallback)
type Context ¶
type Context interface {
Callable() Callable
Id() string
SetMethod(string)
Method() string
LocalFuncDesc() FuncDesc
SetRequestHeader(header RpcMsgHeader)
RequestHeader() RpcMsgHeader
SetResponseHeader(header RpcMsgHeader)
ResponseHeader() RpcMsgHeader
SetRequest(in interface{})
Request() (in interface{})
SetResponse(out interface{})
Response() (out interface{})
RequestType() reflect.Type
SetRequestType(t reflect.Type)
ResponseType() reflect.Type
SetResponseType(t reflect.Type)
ReqMsg() *RawMsg
SetReqMsg(msg *RawMsg)
AckMsg() *RawMsg
SetAckMsg(msg *RawMsg)
FuncDesc() FuncDesc
SetFuncDesc(desc FuncDesc)
SetError(err error)
Error() error
SetWriter(w Writer)
Writer() Writer
AddDefer(deferFunc func())
Reset()
Init(call Callable, inMsg *RawMsg)
BuildOutMsg() (*RawMsg, error)
liblpc.UserDataStorage
}
type Core ¶
type Core interface {
Loop() *liblpc.IOEvtLoop
RegFunc(f interface{}, m ...MiddlewareFunc)
RegFuncWithName(fname string, f interface{}, m ...MiddlewareFunc)
PreUse(m ...MiddlewareFunc)
Use(m ...MiddlewareFunc)
BuildChain(h HandleFunc) HandleFunc
BuildPreUsedChain(h HandleFunc) HandleFunc
Run(ctx context.Context)
Start(ctx context.Context)
GrabContext() Context
ReleaseContext(c Context)
PromiseGroup() *std.PromiseGroup
NotifyCallableRead(call Callable, buf std.ReadableBuffer)
io.Closer
}
type HandleFunc ¶
type HandleFunc func(ctx Context)
type MiddlewareFunc ¶
type MiddlewareFunc func(next HandleFunc) HandleFunc
type RawMsg ¶
type RawMsg struct {
Id string `json:"msgId"`
MethodName string `json:"methodName"`
Headers map[string]string `json:"headers"`
Type MsgType `json:"type"` // req or ack
Err *string `json:"err"` // fast path for ack error
Data []byte `json:"data"` // req = param
}
func (*RawMsg) SetErrorString ¶
type RpcMsgHeader ¶
type SignalCallable ¶
type SignalCallable struct {
Callable
// contains filtered or unexported fields
}
func NewSignalCallable ¶
func NewSignalCallable(call Callable) *SignalCallable
func (*SignalCallable) Close ¶
func (this *SignalCallable) Close() error
func (*SignalCallable) CloseSignal ¶
func (this *SignalCallable) CloseSignal() <-chan error
usage : err,ok := CloseSignal(); !ok -> return , ok -> check error
func (*SignalCallable) ReadySignal ¶
func (this *SignalCallable) ReadySignal() <-chan error
usage : err,ok := ReadySignal(); !ok -> return , ok -> check error
type TimeWheelEntryImpl ¶
func (*TimeWheelEntryImpl) BindTimeWheel ¶
func (this *TimeWheelEntryImpl) BindTimeWheel(timeWheel *liblpc.TimeWheel)
not thread safe
func (*TimeWheelEntryImpl) GetRefCounter ¶
func (this *TimeWheelEntryImpl) GetRefCounter() *int32
func (*TimeWheelEntryImpl) NotifyTimeWheel ¶
func (this *TimeWheelEntryImpl) NotifyTimeWheel()
type VirtualCallable ¶
type VirtualCallable struct {
*BaseCallable
// contains filtered or unexported fields
}
func NewVirtualCallable ¶
func NewVirtualCallable(core Core, writer WriterCloser) *VirtualCallable
func (*VirtualCallable) Close ¶
func (this *VirtualCallable) Close() error
func (*VirtualCallable) MockReadData ¶
func (this *VirtualCallable) MockReadData(data []byte)
not guarantee data seq, don't use in multi goroutine
func (*VirtualCallable) Start ¶
func (this *VirtualCallable) Start()
func (VirtualCallable) Use ¶
func (this VirtualCallable) Use(m ...MiddlewareFunc)
type WriterCloser ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.