Documentation
¶
Index ¶
- Variables
- func GetRequest(ctx context.Context) netx.Request
- func GetResponseHeader(ctx context.Context) netx.Header
- func New(opts ...Option) netx.Server
- func NewRouter() netx.Router
- func SetResponseHeader(ctx context.Context, header netx.Header)
- type BindUnmarshaler
- type Binder
- type Option
- func WithAddr(addr string) Option
- func WithBinder(b Binder) Option
- func WithCodec(v netx.CodecType) Option
- func WithDetector(d netx.Detector) Option
- func WithExec(e netx.Executor) Option
- func WithID(id string) Option
- func WithMetadata(v map[string]string) Option
- func WithModules(m ...netx.Module) Option
- func WithName(name string) Option
- func WithNode(n *registry.Node) Option
- func WithRegistry(r registry.Registry) Option
- func WithRouter(r netx.Router) Option
- func WithSignals(s ...os.Signal) Option
- func WithTran(t netx.Tran) Option
- func WithValidator(v Validator) Option
- func WithVersion(v string) Option
- type Options
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFoundCodec = errors.New("not found codec") ErrNoBinder = errors.New("no binder") )
some error
Functions ¶
func GetRequest ¶
GetRequest 从Context中获取netx.Request
func GetResponseHeader ¶
GetResponseHeader 从Context中获取response header
Types ¶
type BindUnmarshaler ¶
type BindUnmarshaler interface {
// UnmarshalParam decodes and assigns a value from an form or query param.
UnmarshalParam(param string) error
}
BindUnmarshaler is the interface used to wrap the UnmarshalParam method. Types that don't implement this, but do implement encoding.TextUnmarshaler will use that interface instead.
type Option ¶
type Option func(o *Options)
func WithBinder ¶
func WithDetector ¶
func WithMetadata ¶
func WithModules ¶
func WithRegistry ¶
func WithRouter ¶
func WithSignals ¶
func WithValidator ¶
func WithVersion ¶
type Options ¶
type Options struct {
ID string // 唯一ID,如果不指定,则随机生成
Name string // 服务名
Version string // 服务版本
Metadata map[string]string // Meta
Addr string // 监听地址
Tran netx.Tran // Transport
Detector netx.Detector // 协议探测,默认自动探测
Router netx.Router // 路由
Exec netx.Executor // 调度器,默认每条消息一个go routine并发执行
Node *registry.Node // node配置信息
Registry registry.Registry // 服务注册
RegistryTTL time.Duration // 注册过期时间
Signals []os.Signal // 需要监听的事件,默认syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT
Modules []netx.Module // 扩展模块
Binder Binder //
Validator Validator //
Codec netx.CodecType // 默认编解码协议
}
Options 可选配置参数
Source Files
¶
Click to show internal directories.
Click to hide internal directories.