Documentation ¶
Index ¶
- Constants
- func ConvertError(msg string, err ...error) error
- func DBError(msg string, err ...error) error
- func Error(code codes.Code, msg string, err ...error) error
- func FoundError(msg string, err ...error) error
- func InstallCliExt(ctrlName string, mc IMCClient, conf *ConfClient)
- func InstallSerExt(ctrlName string, mc IMCServer, conf *ConfServer, opts ...SerOption)
- func ParseTarget(target string) (scheme, endpoint string, ok bool)
- func RDBError(msg string, err ...error) error
- func ServiceAddr(addr string) *serviceAddr
- func TokenClaims(claimer ITokenClaimser) *tokenClaims
- type ConfClient
- type ConfServer
- type EtcdResolver
- type GClient
- type GServer
- type GrpcOptCred
- type GrpcOptKep
- type GrpcOptRetry
- type GrpcOptTLS
- type IMCClient
- type IMCServer
- type ITokenClaimser
- type ResolverBuild
- type SerOption
- type ServerHost
- type TSerName
Constants ¶
View Source
const ( ECode_Begin codes.Code = iota + 20 // 起始错误码 ECode_DBErr // 数据库错误 ECode_NotFound // 记录找不到 ECode_ParamsErr // 参数错误 ECode_Convert // 结构转换错误 ECode_Logic // 功能逻辑错误 ECode_Cache // 功能缓存错误 )
错误码定义
View Source
const DEF_IP_LEASE_TTL = 3 * time.Second
Variables ¶
This section is empty.
Functions ¶
func InstallCliExt ¶
func InstallCliExt(ctrlName string, mc IMCClient, conf *ConfClient)
安装扩展GClient控制器
func InstallSerExt ¶
func InstallSerExt(ctrlName string, mc IMCServer, conf *ConfServer, opts ...SerOption)
安装扩展GServer控制器
func ParseTarget ¶
检查符合 scheme://authority/endpoint 格式
Types ¶
type ConfClient ¶
type ConfClient struct { Servers []ServerHost `json:"servers"` // 连接选项 GrpcOpts struct { Cred GrpcOptCred `json:"cred"` // 认证 Keep GrpcOptKep `json:"keep"` // 保活 TLS GrpcOptTLS `json:"tls"` // 安全 Balan string `json:"balan"` // 负载均衡(默认:round_robin) Retry GrpcOptRetry `json:"retry"` // 重试 } `json:"grpcOpts"` }
=> 客户端启动配置
type ConfServer ¶
type ConfServer struct { Name string `json:"name"` // 服务名字(用于发现) RunMode string `json:"runMode"` // debug release ListenAddr string `json:"listenAddr"` // 监听地址 IP:Port // 服务选项 GrpcOpts struct { Auth GrpcOptCred `json:"auth"` // 认证 TLS GrpcOptTLS `json:"tls"` // 安全 Keep GrpcOptKep `json:"keep"` // 保活 } `json:"grpcOpts"` }
=> 服务端启动配置
type EtcdResolver ¶
type EtcdResolver struct {
// contains filtered or unexported fields
}
======== 服务地址解析器
func (*EtcdResolver) Close ¶
func (*EtcdResolver) Close()
func (*EtcdResolver) Key ¶
func (this *EtcdResolver) Key() etc.Key
func (*EtcdResolver) ResolveNow ¶
func (*EtcdResolver) ResolveNow(o resolver.ResolveNowOptions)
type GClient ¶
type GClient struct { cto.ControlBase // contains filtered or unexported fields }
=> grpc client control
func (*GClient) HandleInit ¶
func (this *GClient) HandleInit()
func (*GClient) HandleTerm ¶
func (this *GClient) HandleTerm()
type GServer ¶
type GServer struct { cto.ControlBase // contains filtered or unexported fields }
=> gser GServer control
func InstallSer ¶
func InstallSer(ctrlName string, conf *ConfServer, opts ...SerOption) *GServer
安装默认GServer控制器
func (*GServer) HandleInit ¶
func (this *GServer) HandleInit()
func (*GServer) HandleTerm ¶
func (this *GServer) HandleTerm()
type GrpcOptCred ¶
type GrpcOptCred struct { Enable bool `json:"enable"` AuthScheme string `json:"authScheme"` // 起个名(前后端要一致) TokenHeadKey string `json:"tokenHeadKey"` // 默认token, 此key从头中取得token }
连接选项-认证
type GrpcOptKep ¶
type GrpcOptKep struct { Enable bool `json:"enable"` Time int `json:"interval"` // 多久PING一次s 默认10s Timeout int `json:"timeout"` // Ping时的超时s 默认2s WithoutStream bool `json:"withoutStream"` // 保活是否无关流式消息 默认false }
连接选项-保活
type GrpcOptRetry ¶
type GrpcOptRetry struct { Enable bool `json:"enable"` MaxTimes int `json:"maxTimes"` // 重试次数 默认2 TimeoutSec int `json:"timeoutSec"` // 重试超时s 默认2s IntervalSec int `json:"intervalSec"` // 重试间隔s 默认2s,回退0.2 }
连接选项-重试
type GrpcOptTLS ¶
type GrpcOptTLS struct { Enable bool `json:"enable"` SerName string `json:"serName"` CrtFile string `json:"crtFile"` KeyFile string `json:"keyFile"` }
连接选项-TLS
type IMCClient ¶
type IMCClient interface { cto.ICtrlHandler // 获取基类配置 HandleCli() *GClient }
=> GClient 对象接口
type IMCServer ¶
type IMCServer interface { cto.ICtrlHandler // 获取基类配置 HandleSer() *GServer }
=> GServer 对象接口
type ResolverBuild ¶
type ResolverBuild struct {
// contains filtered or unexported fields
}
======== Resolver构建器
func (*ResolverBuild) Build ¶
func (t *ResolverBuild) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error)
func (*ResolverBuild) Scheme ¶
func (t *ResolverBuild) Scheme() string
type ServerHost ¶
type ServerHost struct { Name string `json:"name"` // 给此连接取一个名字 Enable bool `json:"enable"` // 控制是否启用 Endpoint string `json:"endpoint"` // 当是'scheme://authority/endpoint'格式,并且其'authority'是以cloud作为前缀,则启用etcd作为服务发现 }
服务器地址
Click to show internal directories.
Click to hide internal directories.