From 00153963cd230a720295e3dfa702e30b3bd7a70a Mon Sep 17 00:00:00 2001 From: fsdfsffdsf Date: Sun, 9 Jan 2022 09:15:20 +0800 Subject: [PATCH] optimization: config async update branch goroutine num --- conf.sample.yml | 1 + dtmsvr/config/config.go | 19 ++++++++++--------- dtmsvr/svr.go | 5 ++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/conf.sample.yml b/conf.sample.yml index d410988..3c055f4 100644 --- a/conf.sample.yml +++ b/conf.sample.yml @@ -48,6 +48,7 @@ # TimeoutToFail: 35 # timeout for XA, TCC to fail. saga's timeout default to infinite, which can be overwritten in saga options # RetryInterval: 10 # the subtrans branch will be retried after this interval +# UpdateBranchAsyncGoroutineNum: 1 # num of async goroutine to update branch status # LogLevel: 'info' # default: info. can be debug|info|warn|error # HttpPort: 36789 # GrpcPort: 36790 diff --git a/dtmsvr/config/config.go b/dtmsvr/config/config.go index 60f3803..f1877c0 100644 --- a/dtmsvr/config/config.go +++ b/dtmsvr/config/config.go @@ -62,15 +62,16 @@ func (s *Store) GetDBConf() dtmcli.DBConf { } type configType struct { - Store Store `yaml:"Store"` - TransCronInterval int64 `yaml:"TransCronInterval" default:"3"` - TimeoutToFail int64 `yaml:"TimeoutToFail" default:"35"` - RetryInterval int64 `yaml:"RetryInterval" default:"10"` - HTTPPort int64 `yaml:"HttpPort" default:"36789"` - GrpcPort int64 `yaml:"GrpcPort" default:"36790"` - MicroService MicroService `yaml:"MicroService"` - UpdateBranchSync int64 `yaml:"UpdateBranchSync"` - LogLevel string `yaml:"LogLevel" default:"info"` + Store Store `yaml:"Store"` + TransCronInterval int64 `yaml:"TransCronInterval" default:"3"` + TimeoutToFail int64 `yaml:"TimeoutToFail" default:"35"` + RetryInterval int64 `yaml:"RetryInterval" default:"10"` + HTTPPort int64 `yaml:"HttpPort" default:"36789"` + GrpcPort int64 `yaml:"GrpcPort" default:"36790"` + MicroService MicroService `yaml:"MicroService"` + UpdateBranchSync int64 `yaml:"UpdateBranchSync"` + UpdateBranchAsyncGoroutineNum int64 `yaml:"UpdateBranchAsyncGoroutineNum" default:"1"` + LogLevel string `yaml:"LogLevel" default:"info"` } // Config 配置 diff --git a/dtmsvr/svr.go b/dtmsvr/svr.go index ac28c4b..c8fba19 100644 --- a/dtmsvr/svr.go +++ b/dtmsvr/svr.go @@ -46,7 +46,10 @@ func StartSvr() { err := s.Serve(lis) logger.FatalIfError(err) }() - go updateBranchAsync() + + for i := 0; i < int(conf.UpdateBranchAsyncGoroutineNum); i++ { + go updateBranchAsync() + } time.Sleep(100 * time.Millisecond) err = dtmdriver.Use(conf.MicroService.Driver)