Documentation ¶
Overview ¶
Package so goso 各接口的定义
Index ¶
- func ContextLoad(data *ContextData) context.Context
- func ContextWithRouter(ctx context.Context, router interface{}) context.Context
- func ContextWithSeqID(ctx context.Context, seqID int) context.Context
- func ContextWithTraceID(ctx context.Context, traceID string) context.Context
- func ContextWithVersion(ctx context.Context, version string) context.Context
- type Addr
- type Caller
- type ContextData
- type ContextValue
- type GatePack
- type Handler
- type Module
- type Net
- type NetType
- type Proxy
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextLoad ¶ added in v0.0.6
func ContextLoad(data *ContextData) context.Context
ContextLoad 导入
func ContextWithRouter ¶ added in v0.0.6
ContextWithRouter returns a new Context that carries value u.
func ContextWithSeqID ¶ added in v0.0.6
ContextWithSeqID returns a new Context that carries value u.
func ContextWithTraceID ¶ added in v0.0.6
ContextWithTraceID returns a new Context that carries value u.
Types ¶
type ContextData ¶ added in v0.0.6
type ContextData struct { Value *ContextValue `json:"value,omitempty"` Deadline int64 `json:"deadline,omitempty"` }
ContextData 传输用
func ContextDump ¶ added in v0.0.6
func ContextDump(ctx context.Context) *ContextData
ContextDump 导出
type ContextValue ¶ added in v0.0.6
type ContextValue struct { Version string `json:"version,omitempty"` // TraceID string `json:"trace_id,omitempty"` // 服务端ID SeqID int `json:"seq_id,omitempty"` // 客户端ID Router interface{} `json:"router,omitempty"` // 路由器 }
ContextValue 上下文结构体
func ContextFetchValue ¶ added in v0.0.7
func ContextFetchValue(ctx context.Context) (*ContextValue, bool)
ContextFetchValue returns the User value stored in ctx, if any.
func (*ContextValue) String ¶ added in v0.0.7
func (v *ContextValue) String() string
String 添加 stringer 方法
type GatePack ¶
type GatePack interface { Verify() error // 校验包的有效性 GetRouter() Router // 获取路由 GetLogicPack() interface{} // 获取业务对象 GetContext() context.Context // 获取上下文 }
GatePack 网关包对象
type Handler ¶
type Handler interface { IsAnyNet(netType NetType) bool // 是否某个网络的处理器 GetName() string // 名称 GetRouter() (routers []Router) // 路由器对象 允许多个路由器指向相同处理器 router 如果是结构体必须提供 String() 方法 CloneReq() interface{} // 克隆一个请求结构体的新指针 CloneResp() interface{} // 克隆一个响应结构体的新指针 Handle(ctx context.Context, req, resp interface{}) error }
Handler 处理器定义
type Net ¶
type Net interface { SetGatePack(gatePack GatePack) error // gnet 需要 Register(handler Handler) error Start() error Stop() error }
Net ��网络传输服务
type Proxy ¶
type Proxy interface { IsHandler(ctx context.Context, router Router) (bool, error) // 判断是否本进程内能处理 RegisterCaller(nodeID string, hander Handler) error // 注册 FetchOneCaller(ctx context.Context, router Router) (caller Caller, err error) // 按照默认策略获取一个caller FetchTheCaller(ctx context.Context, router Router, addr *Addr) (caller Caller, err error) // 获取一个指定caller FetchAllCaller(ctx context.Context, router Router) (callers []Caller, err error) // 获取所有caller }
Proxy ��获取handler或caller
Click to show internal directories.
Click to hide internal directories.