1 Star 0 Fork 0

micro-tools/micro

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
options.go 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
545403892 提交于 2023-06-05 23:58 +08:00 . init
package module
import (
"gitee.com/micro-tools/wf/extend/utils/gmicro/registry"
"gitee.com/micro-tools/wf/extend/utils/gmicro/selector"
"gitee.com/micro-tools/wf/os/glog"
"time"
)
// Option 配置项
type Option func(*Options)
type Trace struct {
Status bool
Name string
URL string
}
type Options struct {
Version string
Debug bool
Tracing Trace
Log *glog.Logger
KillWaitTTL time.Duration
RegistryEnable bool //是否使用注册中心
Registry registry.Registry
RegisterInterval time.Duration
RegisterTTL time.Duration
Port int
Selector selector.Selector
RPCExpired time.Duration
}
func Version(version string) Option {
return func(o *Options) {
o.Version = version
}
}
func Debug(t bool) Option {
return func(o *Options) {
o.Debug = t
}
}
func Tracing(t Trace) Option {
return func(o *Options) {
o.Tracing = t
}
}
func Port(port int) Option {
return func(o *Options) {
o.Port = port
}
}
// KillWaitTTL specifies the interval on which to re-register
func KillWaitTTL(t time.Duration) Option {
return func(o *Options) {
o.KillWaitTTL = t
}
}
// RegisterTTL specifies the TTL to use when registering the service
func RegisterTTL(t time.Duration) Option {
return func(o *Options) {
o.RegisterTTL = t
}
}
// RegisterInterval specifies the interval on which to re-register
func RegisterInterval(t time.Duration) Option {
return func(o *Options) {
o.RegisterInterval = t
}
}
// Registry sets the registry for the service
// and the underlying components
func Registry(r registry.Registry) Option {
return func(o *Options) {
o.Registry = r
}
}
// RegistryEnable sets the registry for the service status open or close
func RegistryEnable(status bool) Option {
return func(o *Options) {
o.RegistryEnable = status
}
}
//RPC超时时间
func RPCExpired(t time.Duration) Option {
return func(o *Options) {
o.RPCExpired = t
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/micro-tools/micro.git
git@gitee.com:micro-tools/micro.git
micro-tools
micro
micro
v1.0.2

搜索帮助