so

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package so goso 各接口的定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 ContextKey

type ContextKey interface {
	String() string
}

ContextKey ContextKey

func ContextRevert

func ContextRevert(k string) ContextKey

ContextRevert 还原

type ContextRouter

type ContextRouter struct{}

ContextRouter 路由

func (*ContextRouter) String

func (ctx *ContextRouter) String() string

type ContextSeqID

type ContextSeqID struct{}

ContextSeqID 客户端包

func (*ContextSeqID) String

func (ctx *ContextSeqID) String() string

type ContextTraceID

type ContextTraceID struct{}

ContextTraceID 服务端包ID

func (*ContextTraceID) String

func (ctx *ContextTraceID) String() string

type ContextVersion

type ContextVersion struct{}

ContextVersion 版本

func (*ContextVersion) String

func (ctx *ContextVersion) String() string

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() 方法
	GetReq() interface{}           // 请求结构体 空结构体 指针
	GetResp() 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