upgrade github.com/alimy/tryst => v0.10.0

pull/415/head
Michael Li 9 months ago
parent 98ec6fea2c
commit 7eb3ee8896
No known key found for this signature in database

@ -7,7 +7,7 @@ require (
github.com/RoaringBitmap/roaring v1.6.0
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/mir/v4 v4.0.0
github.com/alimy/tryst v0.9.4
github.com/alimy/tryst v0.10.0
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/bufbuild/connect-go v1.10.0

@ -127,8 +127,8 @@ github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:C
github.com/alexflint/go-filemutex v1.1.0/go.mod h1:7P4iRhttt/nUvUOrYIhcpMzv2G6CY9UnI16Z+UJqRyk=
github.com/alimy/mir/v4 v4.0.0 h1:MzGfmoLjjvR69jbZEmpKJO3tUuqB0RGRv1UWPbtukBg=
github.com/alimy/mir/v4 v4.0.0/go.mod h1:d58dBvw2KImcVbAUANrciEV/of0arMNsI9c/5UNCMMc=
github.com/alimy/tryst v0.9.4 h1:faM0BwgcU7mxdEF2lG8c45iXXkEPEYvBd0oLBrNa1yM=
github.com/alimy/tryst v0.9.4/go.mod h1:6FcqEImav7S62em+p+MODh+stt/UPp23HobUOK3XwFY=
github.com/alimy/tryst v0.10.0 h1:uiwUk/WFCkpLT6bBW8GmRT8k60/CM5dQlyc/osxYty4=
github.com/alimy/tryst v0.10.0/go.mod h1:6FcqEImav7S62em+p+MODh+stt/UPp23HobUOK3XwFY=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible h1:Sg/2xHwDrioHpxTN6WMiwbXTpUEinBpHsN7mG21Rc2k=
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk=

@ -128,8 +128,8 @@ func setupSetting(suite []string, noDefault bool) error {
}
CacheSetting.CientSideCacheExpire *= time.Second
EventManagerSetting.TickWaitTime *= time.Second
MetricManagerSetting.TickWaitTime *= time.Second
EventManagerSetting.MaxIdleTime *= time.Second
MetricManagerSetting.MaxIdleTime *= time.Second
JWTSetting.Expire *= time.Second
SimpleCacheIndexSetting.CheckTickDuration *= time.Second
SimpleCacheIndexSetting.ExpireTickDuration *= time.Second

@ -25,14 +25,13 @@ EventManager: # 事件管理器的配置参数
MaxTempWorker: -1 # 最大临时工作者, -1为无限制, 默认-1
MaxEventBuf: 128 # 最大log缓存条数, 设置范围[10, ++], 默认128
MaxTempEventBuf: 256 # 最大log缓存条数, 设置范围[10, ++], 默认256
MaxTickCount: 60 # 最大的循环周期, 设置范围[60, ++], 默认60
TickWaitTime: 1 # 一个周期的等待时间,单位:秒 默认1s
MaxIdleTime: 60 # 临时工作者最大空闲等待时间,单位:秒 默认60
MetricManager: # 指标监控管理器的配置参数
MinWorker: 32 # 最小后台工作者, 设置范围[5, ++], 默认32
MaxTempWorker: -1 # 最大临时工作者, -1为无限制, 默认-1
MaxEventBuf: 128 # 最大log缓存条数, 设置范围[10, ++], 默认128
MaxTempEventBuf: 256 # 最大log缓存条数, 设置范围[10, ++], 默认256
MaxTickCount: 60 # 最大的循环周期, 设置范围[60, ++], 默认60
TickWaitTime: 1 # 一个周期的等待时间,单位:秒 默认1s
MaxIdleTime: 60 # 临时工作者最大空闲等待时间,单位:秒 默认60
JobManager: # Cron Job理器的配置参数
MaxOnlineInterval: "@every 5m" # 更新最大在线人数默认每5分钟更新一次
UpdateMetricsInterval: "@every 5m" # 更新Prometheus指标默认每5分钟更新一次

@ -56,8 +56,7 @@ func newObserveLogHook() *observeLogHook {
MinWorker: s.MinWorker,
MaxRequestBuf: s.MaxLogBuffer,
MaxRequestTempBuf: 100,
MaxTickCount: 60,
TickWaitTime: time.Second,
MaxIdleTime: 60 * time.Second,
}
return &observeLogHook{
client: obx.NewClient(obc, acc, func(req *http.Request, resp *http.Response, err error) {

@ -118,16 +118,15 @@ type eventManagerConf struct {
MaxTempWorker int
MaxEventBuf int
MaxTempEventBuf int
MaxTickCount int
TickWaitTime time.Duration
MaxIdleTime time.Duration
}
type metricManagerConf struct {
MinWorker int
MaxTempWorker int
MaxEventBuf int
MaxTempEventBuf int
MaxTickCount int
TickWaitTime time.Duration
MaxIdleTime time.Duration
}
type jobManagerConf struct {

@ -90,24 +90,24 @@ func initEventManager() {
var opts []pool.Option
s := conf.EventManagerSetting
if s.MinWorker > 5 {
opts = append(opts, pool.MinWorkerOpt(s.MinWorker))
opts = append(opts, pool.WithMinWorker(s.MinWorker))
} else {
opts = append(opts, pool.MinWorkerOpt(5))
opts = append(opts, pool.WithMinWorker(5))
}
if s.MaxEventBuf > 10 {
opts = append(opts, pool.MaxRequestBufOpt(s.MaxEventBuf))
opts = append(opts, pool.WithMaxRequestBuf(s.MaxEventBuf))
} else {
opts = append(opts, pool.MaxRequestBufOpt(10))
opts = append(opts, pool.WithMaxRequestBuf(10))
}
if s.MaxTempEventBuf > 10 {
opts = append(opts, pool.MaxRequestTempBufOpt(s.MaxTempEventBuf))
opts = append(opts, pool.WithMaxRequestTempBuf(s.MaxTempEventBuf))
} else {
opts = append(opts, pool.MaxRequestTempBufOpt(10))
opts = append(opts, pool.WithMaxRequestTempBuf(10))
}
if cfg.If("Metrics") {
opts = append(opts, pool.WorkerHookOpt(NewEventWorkerHook("default", statistics.NewMetricCache())))
opts = append(opts, pool.WithWorkerHook(NewEventWorkerHook("default", statistics.NewMetricCache())))
}
opts = append(opts, pool.MaxTickCountOpt(s.MaxTickCount), pool.TickWaitTimeOpt(s.TickWaitTime), pool.MaxTempWorkerOpt(s.MaxTempWorker))
opts = append(opts, pool.WithMaxIdelTime(s.MaxIdleTime), pool.WithMaxTempWorker(s.MaxTempWorker))
_defaultEventManager = NewEventManager(func(req Event, err error) {
if err != nil {
logrus.Errorf("handle event[%s] occurs error: %s", req.Name(), err)

@ -49,23 +49,23 @@ func Initial() {
func initMetricManager() {
var opts []pool.Option
s := conf.EventManagerSetting
s := conf.MetricManagerSetting
if s.MinWorker > 5 {
opts = append(opts, pool.MinWorkerOpt(s.MinWorker))
opts = append(opts, pool.WithMinWorker(s.MinWorker))
} else {
opts = append(opts, pool.MinWorkerOpt(5))
opts = append(opts, pool.WithMinWorker(5))
}
if s.MaxEventBuf > 10 {
opts = append(opts, pool.MaxRequestBufOpt(s.MaxEventBuf))
opts = append(opts, pool.WithMaxRequestBuf(s.MaxEventBuf))
} else {
opts = append(opts, pool.MaxRequestBufOpt(10))
opts = append(opts, pool.WithMaxRequestBuf(10))
}
if s.MaxTempEventBuf > 10 {
opts = append(opts, pool.MaxRequestTempBufOpt(s.MaxTempEventBuf))
opts = append(opts, pool.WithMaxRequestTempBuf(s.MaxTempEventBuf))
} else {
opts = append(opts, pool.MaxRequestTempBufOpt(10))
opts = append(opts, pool.WithMaxRequestTempBuf(10))
}
opts = append(opts, pool.MaxTickCountOpt(s.MaxTickCount), pool.TickWaitTimeOpt(s.TickWaitTime), pool.MaxTempWorkerOpt(s.MaxTempWorker))
opts = append(opts, pool.WithMaxIdelTime(s.MaxIdleTime), pool.WithMaxTempWorker(s.MaxTempWorker))
_defaultMetricManager = event.NewEventManager(func(req Metric, err error) {
if err != nil {
logrus.Errorf("handle event[%s] occurs error: %s", req.Name(), err)

@ -34,8 +34,7 @@ type AsyncClientConf struct {
MinWorker int
MaxRequestBuf int
MaxRequestTempBuf int
MaxTickCount int
TickWaitTime time.Duration
MaxIdleTime time.Duration
}
type wormClient struct {
@ -64,11 +63,10 @@ func NewAsyncClient(client *http.Client, conf *AsyncClientConf) AsyncClient {
pool: gp.NewGoroutinePool(func(req *http.Request) (*http.Response, error) {
return client.Do(req)
},
gp.MinWorkerOpt(minWorker),
gp.MaxRequestBufOpt(maxRequestBuf),
gp.MaxRequestTempBufOpt(maxRequestTempBuf),
gp.MaxTickCountOpt(conf.MaxTickCount),
gp.TickWaitTimeOpt(conf.TickWaitTime),
gp.WithMinWorker(minWorker),
gp.WithMaxRequestBuf(maxRequestBuf),
gp.WithMaxRequestTempBuf(maxRequestTempBuf),
gp.WithMaxIdelTime(conf.MaxIdleTime),
),
}
}

Loading…
Cancel
Save