Documentation ¶
Index ¶
- Constants
- Variables
- func SemicolonMiddleware() gin.HandlerFunc
- type AuthOption
- type Authenticator
- type CallQueue
- type Context
- type GroupRouteInfo
- type HttpProxy
- func (hp *HttpProxy) AddGroupRoute(groupName string, auth Authenticator, routes ...*GroupRouteInfo) error
- func (hp *HttpProxy) AddRoute(method string, path string, handle RouteHandle, auth Authenticator) error
- func (hp *HttpProxy) CallPlatoRpc(serviceName string, methodName string, params string) ([]byte, error)
- func (hp *HttpProxy) CallPlatoRpcRaw(name string, method string, rawData []byte) ([]byte, error)
- func (hp *HttpProxy) Init(option *Options) error
- func (hp *HttpProxy) IsResolved() bool
- func (hp *HttpProxy) OnRpcResponse(ret *protocol.ProxyRespPackage) error
- func (hp *HttpProxy) SetHttpRequestHandle(handle ProxyRequestHandle)
- func (hp *HttpProxy) SetOptions(options ...Option)
- func (hp *HttpProxy) ShutDown()
- func (hp *HttpProxy) Start() error
- func (hp *HttpProxy) Tick()
- type IRpcRequest
- type JWTAuthenticator
- type Option
- type Options
- type ProxyRequestHandle
- type ProxyWriter
- type Response
- type RouteHandle
- type RpcContext
Constants ¶
View Source
const ( StatusClosed = iota //服务已经关闭 StatusResolved //服务正在运行 StatusUpdating //服务正在更新 StatusClosing //服务正在关闭 )
Variables ¶
View Source
var ( ErrInvalidHttpAddress = errors.New("invalid http address ") ErrNoEffectiveServicePath = errors.New("no effective service config path ") ErrInitServiceDBError = errors.New("create service data base error ") ErrRequestNotFound = errors.New("http call info not found ") ErrRequestExpired = errors.New("the http request has expired ") ErrRoutePathExist = errors.New("route path already exists") ErrCertificateNotExist = errors.New("certificate file does not exist") ErrInvalidTokenType = errors.New("invalid token type") )
Functions ¶
func SemicolonMiddleware ¶
func SemicolonMiddleware() gin.HandlerFunc
Types ¶
type AuthOption ¶ added in v0.4.31
type AuthOption struct { Enable bool `yaml:"enable"` //Enable 是否开启校验 PublicKeyPath string `yaml:"public_key_path"` //PublicKeyPath 公钥路径 AuthHeader string `yaml:"auth_header"` //AuthHeader http头部中用于鉴权的字段名 TokenType string `yaml:"token_type"` //TokenType token 类型 如 Bearer }
func NewAuthOption ¶ added in v0.4.31
func NewAuthOption() *AuthOption
type Context ¶
Context http_proxy 上下文,对外屏蔽内部使用的框架, 便于框架内部迭代而不影响外部api
func (*Context) GetRpcContext ¶ added in v0.5.3
func (ctx *Context) GetRpcContext() *RpcContext
func (*Context) SetRpcContext ¶ added in v0.5.3
type GroupRouteInfo ¶ added in v0.4.19
type GroupRouteInfo struct { Method string // method type, GET POST PUT Path string //API 路径 Handle RouteHandle //处理函数 }
GroupRouteInfo 添加GroupAPI
type HttpProxy ¶
type HttpProxy struct {
// contains filtered or unexported fields
}
HttpProxy http 代理,启动http服务器,将收到http 转化为 plato rpc协议
func MakeHttpProxy ¶
func (*HttpProxy) AddGroupRoute ¶ added in v0.4.19
func (hp *HttpProxy) AddGroupRoute(groupName string, auth Authenticator, routes ...*GroupRouteInfo) error
AddGroupRoute 添加自定义groupName, 使用auth 函数对组内所有 handle api进行鉴权, 鉴权函数可以为空
func (*HttpProxy) AddRoute ¶ added in v0.4.19
func (hp *HttpProxy) AddRoute(method string, path string, handle RouteHandle, auth Authenticator) error
AddRoute 添加自定义的API路径path, 执行函数handle, 以及是否需要使用auth 进行鉴权,鉴权函数可以为空
func (*HttpProxy) CallPlatoRpc ¶ added in v0.5.17
func (hp *HttpProxy) CallPlatoRpc(serviceName string, methodName string, params string) ([]byte, error)
CallPlatoRpc 原生调用plato rpc协议
func (*HttpProxy) CallPlatoRpcRaw ¶ added in v0.5.18
func (*HttpProxy) OnRpcResponse ¶
func (hp *HttpProxy) OnRpcResponse(ret *protocol.ProxyRespPackage) error
func (*HttpProxy) SetHttpRequestHandle ¶
func (hp *HttpProxy) SetHttpRequestHandle(handle ProxyRequestHandle)
func (*HttpProxy) SetOptions ¶ added in v0.4.31
type IRpcRequest ¶ added in v0.5.18
type IRpcRequest interface {
// contains filtered or unexported methods
}
IRpcRequest rpc 请求接口
type JWTAuthenticator ¶ added in v0.4.31
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
JWTAuthenticator JWT Token校验鉴权工具,框架内置默认的鉴权工具
func NewJWTAuthenticator ¶ added in v0.4.31
func NewJWTAuthenticator(opt *AuthOption) *JWTAuthenticator
func (*JWTAuthenticator) Authenticate ¶ added in v0.4.31
func (t *JWTAuthenticator) Authenticate(ctx *Context) error
type Option ¶
type Option func(options *Options)
Option 设置函数
func WithAuthenticator ¶ added in v0.4.31
func WithAuthenticator(authenticator Authenticator) Option
func WithCustomLogger ¶
func WithJwtAuthenticator ¶ added in v0.4.31
func WithJwtAuthenticator(authOpt *AuthOption) Option
type Options ¶
type Options struct { Address string `yaml:"address"` //监听地址 ServicePath string `yaml:"service_path"` //服务配置路径 Mode string `yaml:"mode"` //运行模式 debug release ShutdownTimeout uint32 `yaml:"shutdown_timeout"` //停机超时时间, 单位毫秒 CacheSize uint32 `yaml:"cache_size"` //命令排队数量,默认是1024,框架处理速率是每秒 5000 条命令左右 不应该有太多堆积 SSLKey string `yaml:"ssl_key"` //https 私聊 SSLPem string `yaml:"ssl_pem"` //https 证书 InternalMode bool `yaml:"internal_mode"` //内部模式 PbCoderName string `yaml:"pb_coder_name"` //pb-coder的名称 PbVersion int `yaml:"pb_version"` //pb版本 // contains filtered or unexported fields }
Options http proxy 模块配置
func NewDefaultOptions ¶ added in v0.4.24
func NewDefaultOptions() *Options
type ProxyRequestHandle ¶
type ProxyRequestHandle func(req *protocol.ProxyRequestPackage) (uint32, error)
ProxyRequestHandle http 请求转换为rpc 请求后回调函数 成功返回 call id 和 nil 错误; 失败 则返回0 和具体错误
type ProxyWriter ¶
type ProxyWriter struct {
// contains filtered or unexported fields
}
ProxyWriter 日志包装器
type RpcContext ¶ added in v0.5.3
Click to show internal directories.
Click to hide internal directories.