diff --git a/pkg/client/client.go b/pkg/client/client.go index 9508a8ba7..3b1e2433f 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -20,13 +20,12 @@ package client import ( "sync" - "github.com/seata/seata-go/pkg/tm" - at "github.com/seata/seata-go/pkg/datasource/sql" "github.com/seata/seata-go/pkg/integration" "github.com/seata/seata-go/pkg/remoting/getty" "github.com/seata/seata-go/pkg/remoting/processor/client" "github.com/seata/seata-go/pkg/rm/tcc" + "github.com/seata/seata-go/pkg/tm" "github.com/seata/seata-go/pkg/util/log" ) @@ -39,7 +38,6 @@ func Init() { func InitPath(configFilePath string) { cfg := LoadPath(configFilePath) - initLog(cfg) initRmClient(cfg) initTmClient(cfg) } @@ -47,13 +45,11 @@ func InitPath(configFilePath string) { var ( onceInitTmClient sync.Once onceInitRmClient sync.Once - onceInitLog sync.Once ) // InitTmClient init client tm client func initTmClient(cfg *Config) { onceInitTmClient.Do(func() { - initRemoting(cfg) tm.InitTm(cfg.ClientConfig.TmConfig) }) } @@ -71,16 +67,11 @@ func initRemoting(cfg *Config) { // InitRmClient init client rm client func initRmClient(cfg *Config) { onceInitRmClient.Do(func() { + log.Init() + initRemoting(cfg) client.RegisterProcessor() integration.Init() tcc.InitTCC() at.InitAT(cfg.ClientConfig.UndoConfig, cfg.AsyncWorkerConfig) }) } - -// initLog init log -func initLog(cfg *Config) { - onceInitLog.Do(func() { - log.Init() - }) -} diff --git a/pkg/remoting/getty/listener.go b/pkg/remoting/getty/listener.go index 4f014245c..4da096b3f 100644 --- a/pkg/remoting/getty/listener.go +++ b/pkg/remoting/getty/listener.go @@ -36,7 +36,6 @@ var ( ) type gettyClientHandler struct { - conf *SeataConfig idGenerator *atomic.Uint32 msgFutures *sync.Map mergeMsgMap *sync.Map @@ -48,7 +47,6 @@ func GetGettyClientHandlerInstance() *gettyClientHandler { if clientHandler == nil { onceClientHandler.Do(func() { clientHandler = &gettyClientHandler{ - conf: getSeataConfig(), idGenerator: &atomic.Uint32{}, msgFutures: &sync.Map{}, mergeMsgMap: &sync.Map{}, @@ -63,11 +61,12 @@ func GetGettyClientHandlerInstance() *gettyClientHandler { func (g *gettyClientHandler) OnOpen(session getty.Session) error { log.Infof("Open new getty session ") g.sessionManager.registerSession(session) + conf := getSeataConfig() go func() { request := message.RegisterTMRequest{AbstractIdentifyRequest: message.AbstractIdentifyRequest{ Version: constant.SeataVersion, - ApplicationId: g.conf.ApplicationID, - TransactionServiceGroup: g.conf.TxServiceGroup, + ApplicationId: conf.ApplicationID, + TransactionServiceGroup: conf.TxServiceGroup, }} err := GetGettyRemotingClient().SendAsyncRequest(request) if err != nil {