Documentation
¶
Overview ¶
Package srv is the Go implementation of server, which is designed to be high-performance, everything-pluggable and easy for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultServerCloseSIG = []os.Signal{syscall.SIGINT, syscall.SIGTERM, syscall.SIGSEGV, syscall.SIGUSR2}
DefaultServerCloseSIG are signals that close server.
View Source
var New = func(opts *Options) Service { s := &service{ opts: opts, handlers: make(map[string]Handler), } s.opts.TransportOptions.Handler = s s.ctx, s.cancel = context.WithCancel(context.Background()) return s }
New create service
Functions ¶
func SetClosing ¶
func SetClosing()
Types ¶
type Handler ¶
type Handler func(ctx context.Context, reqHeader *proto.RequestHeader, reqBodyBuf []byte) (rsp interface{}, err error)
Handler is the default handler.
type Options ¶
type Options struct {
Machine string // 机器名(容器名)
Env string // 环境名
ServiceName string // 服务名
Address string // 监听地址
Protocol string // 服务协议,如 rpc、http、web
Timeout time.Duration // 请求处理超时时间
Registry naming.Registry // 名字服务注册接口
Transport transport.Transport // 传输层
TransportOptions transport.Options // 传输层配置
Codec codec.Codec // 编解码接口
CloseWaitTime time.Duration // 注销名字服务之后的等待时间,让名字服务更新实例列表。 (单位 ms) 最大: 10s.
MaxCloseWaitTime time.Duration // 进程结束之前等待请求完成的最大等待时间。(单位 ms)
}
Options are server side options.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codec defines the business communication protocol of packing and unpacking.
|
Package codec defines the business communication protocol of packing and unpacking. |
|
Package registry registers servers.
|
Package registry registers servers. |
|
Package transport is the network client layer.
|
Package transport is the network client layer. |
|
http
Package http provides support for http protocol by default, provides rpc server with http protocol, and provides rpc database for calling http protocol.
|
Package http provides support for http protocol by default, provides rpc server with http protocol, and provides rpc database for calling http protocol. |
Click to show internal directories.
Click to hide internal directories.