Skip to content

Commit

Permalink
bugfix: repair init getty failed (#423)
Browse files Browse the repository at this point in the history
* bugfix: repair init getty failed
  • Loading branch information
lxfeng1997 authored Jan 2, 2023
1 parent 27fb163 commit 99d9a9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
15 changes: 3 additions & 12 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -39,21 +38,18 @@ func Init() {
func InitPath(configFilePath string) {
cfg := LoadPath(configFilePath)

initLog(cfg)
initRmClient(cfg)
initTmClient(cfg)
}

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)
})
}
Expand All @@ -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()
})
}
7 changes: 3 additions & 4 deletions pkg/remoting/getty/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (
)

type gettyClientHandler struct {
conf *SeataConfig
idGenerator *atomic.Uint32
msgFutures *sync.Map
mergeMsgMap *sync.Map
Expand All @@ -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{},
Expand All @@ -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 {
Expand Down

0 comments on commit 99d9a9d

Please sign in to comment.