Documentation
¶
Index ¶
- type Option
- func OptBodyCodec(c string) Option
- func OptContextAge(n time.Duration) Option
- func OptEnableHeartbeat(t bool) Option
- func OptGlobalPlugin(plugin ...drpc.Plugin) Option
- func OptListenAddress(addr string) Option
- func OptMetrics(m metrics.Metrics) Option
- func OptNetwork(net string) Option
- func OptPrintDetail(c bool) Option
- func OptProtoFunc(pf proto.ProtoFunc) Option
- func OptRegistry(r registry.Registry) Option
- func OptServiceName(name string) Option
- func OptServiceVersion(version string) Option
- func OptSessionAge(n time.Duration) Option
- func OptSlowCometDuration(n time.Duration) Option
- func OptTlsConfig(config *tls.Config) Option
- func OptTlsFile(tlsCertFile string, tlsKeyFile string) Option
- type Options
- type RpcServer
- func (that *RpcServer) Close()
- func (that *RpcServer) CountSession() int
- func (that *RpcServer) Endpoint() drpc.Endpoint
- func (that *RpcServer) GetSession(sessionId string) (drpc.Session, bool)
- func (that *RpcServer) ListenAndServe(protoFunc ...proto.ProtoFunc) error
- func (that *RpcServer) Options() Options
- func (that *RpcServer) RouteCall(ctrlStruct interface{}, plugin ...drpc.Plugin) []string
- func (that *RpcServer) RouteCallFunc(callHandleFunc interface{}, plugin ...drpc.Plugin) string
- func (that *RpcServer) RoutePush(ctrlStruct interface{}, plugin ...drpc.Plugin) []string
- func (that *RpcServer) RoutePushFunc(pushHandleFunc interface{}, plugin ...drpc.Plugin) string
- func (that *RpcServer) Router() *drpc.Router
- func (that *RpcServer) ServeConn(conn net.Conn, protoFunc ...proto.ProtoFunc) (drpc.Session, *drpc.Status)
- func (that *RpcServer) SetUnknownCall(fn func(drpc.UnknownCallCtx) (interface{}, *drpc.Status), ...)
- func (that *RpcServer) SetUnknownPush(fn func(drpc.UnknownPushCtx) *drpc.Status, plugin ...drpc.Plugin)
- func (that *RpcServer) SubRoute(pathPrefix string, plugin ...drpc.Plugin) *drpc.SubRouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
func OptSlowCometDuration ¶
OptSlowCometDuration 设置慢请求的定义时间
type Options ¶
type Options struct { Context context.Context // 上下文 ServiceName string // 服务名称 ServiceVersion string // 服务版本 Network string // 网络类型 ListenAddress string // 要监听的地址 TlsCertFile string TlsKeyFile string TLSConfig *tls.Config ProtoFunc proto.ProtoFunc SessionAge time.Duration ContextAge time.Duration SlowCometDuration time.Duration BodyCodec string PrintDetail bool Registry registry.Registry GlobalPlugin []drpc.Plugin EnableHeartbeat bool Metrics metrics.Metrics // 统计信息 }
func (Options) EndpointConfig ¶
func (that Options) EndpointConfig() drpc.EndpointConfig
type RpcServer ¶
type RpcServer struct {
// contains filtered or unexported fields
}
RpcServer rpc服务端
func NewRpcServer ¶
NewRpcServer 创建rpcServer
func (*RpcServer) GetSession ¶
GetSession 通过session id获取session
func (*RpcServer) ListenAndServe ¶
ListenAndServe 启动并监听服务
func (*RpcServer) RouteCallFunc ¶
RouteCallFunc 通过func注册CALL处理方法,返回资源标识符
func (*RpcServer) RoutePushFunc ¶
RoutePushFunc 通过func注册PUSH处理方法,返回资源标识符
func (*RpcServer) ServeConn ¶
func (that *RpcServer) ServeConn(conn net.Conn, protoFunc ...proto.ProtoFunc) (drpc.Session, *drpc.Status)
ServeConn 传入指定的conn,生成session 提示: 1. 不支持断开链接后自动重拨 2. 不检查TLS 3. 执行 PostAcceptPlugin 插件
func (*RpcServer) SetUnknownCall ¶
func (that *RpcServer) SetUnknownCall(fn func(drpc.UnknownCallCtx) (interface{}, *drpc.Status), plugin ...drpc.Plugin)
SetUnknownCall 设置默认处理方法 当请求call类型的资源标识符不存在时,则执行其设置的方法
func (*RpcServer) SetUnknownPush ¶
func (that *RpcServer) SetUnknownPush(fn func(drpc.UnknownPushCtx) *drpc.Status, plugin ...drpc.Plugin)
SetUnknownPush 设置默认处理方法
当请求push类型的资源标识符不存在时,则执行其设置的方法
Click to show internal directories.
Click to hide internal directories.