Documentation
¶
Index ¶
- func GetRegisterMethods(name string) ([]string, error)
- func NewService(opts ...Option) *service
- func Register(rcvr any, name string, opts ...Option) error
- func SetRecoveryHandler(handle func(string, any))
- type AccessHandle
- type Dispatcher
- type Gate
- type GateAgent
- type Option
- type Options
- type SkynetContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRegisterMethods ¶
func NewService ¶
func NewService(opts ...Option) *service
func Register ¶
Register publishes uses the provided name in the dispatcher the set of methods of the receiver value that satisfy the following conditions:
- exported method of exported type
- two arguments, both of exported type
- the second argument is a pointer
- one return value, of type error
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func SetRecoveryHandler ¶
By default, it will print the time and stack information of the error
Types ¶
type AccessHandle ¶
type AccessHandle func(ctx *SkynetContext, sname, method string, cost time.Duration, err error)
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
dispatcher represents an RPC disoatcher.
func GetDispatcher ¶
func GetDispatcher() *Dispatcher
func (*Dispatcher) DispatchReq ¶
func (*Dispatcher) GetService ¶ added in v1.1.0
func (disp *Dispatcher) GetService(sname string) *service
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
func (*Gate) Close ¶
Close is used to graceful exit. It will close all idle connections on the server, but will not change the underlying pollers.
type GateAgent ¶
type GateAgent struct {
Reader chan netpoll.Reader // use for reader socket data
// contains filtered or unexported fields
}
func NewGateAgent ¶
func NewGateAgent(conn netpoll.Connection) *GateAgent
func (*GateAgent) ResponseErr ¶
func (*GateAgent) ResponseOk ¶
type Option ¶
type Option func(*Options)
func WithAccessLog ¶
func WithAccessLog(hdl AccessHandle) Option
func WithMonitorInterval ¶ added in v1.1.0
Synchronous mode monitor message maybe in endlessloop interval. Default 5 time.Seconds. must greate than 1 time.Seconds
func WithPayloadCodec ¶
func WithPayloadCodec(c codec.PayloadCodec) Option
func WithSyncDispatch ¶ added in v1.1.0
func WithSyncDispatch() Option
Default Message dispatch mod is async. The order of messages is not guaranteed. SyncDispatch guarenteed order of messages. But be careful of endlessloop
type Options ¶
type Options struct {
PayloadCodec codec.PayloadCodec
AccessHdle AccessHandle
SyncDisptch bool
MonitorInterval time.Duration
}
type SkynetContext ¶
func NewSkynetContext ¶
func NewSkynetContext(ctx context.Context) *SkynetContext