so

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package so goso 各接口的定义

Index

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

func ContextWithRouter(ctx context.Context, router interface{}) context.Context

ContextWithRouter returns a new Context that carries value u.

func ContextWithSeqID added in v0.0.6

func ContextWithSeqID(ctx context.Context, seqID int) context.Context

ContextWithSeqID returns a new Context that carries value u.

func ContextWithTraceID added in v0.0.6

func ContextWithTraceID(ctx context.Context, traceID string) context.Context

ContextWithTraceID returns a new Context that carries value u.

func ContextWithVersion added in v0.0.6

func ContextWithVersion(ctx context.Context, version string) context.Context

ContextWithVersion returns a new Context that carries value u.

Types

type Addr

type Addr struct {
	IP   string
	Port int
}

Addr 地址

func (*Addr) String

func (addr *Addr) String() string

type Caller

type Caller interface {
	Call(ctx context.Context, req, resp interface{}) error
}

Caller 远程调用handler的封装

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 Module

type Module interface {
	Start() error
	Stop() error
}

Module 模块 需要注册的模块定义

type Net

type Net interface {
	SetGatePack(gatePack GatePack) error // gnet 需要
	Register(handler Handler) error
	Start() error
	Stop() error
}

Net ��网络传输服务

type NetType

type NetType int

NetType 网络类型

const (
	NetTypeNNet NetType = iota
	NetTypeGNet
	NetTypeLNet
)

网络类型

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

type Router added in v0.0.3

type Router interface {
	String() string
}

Router 路由对象

Jump to

Keyboard shortcuts

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