Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use config #436

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"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"
"github.com/seata/seata-go/pkg/rm/tcc"
"github.com/seata/seata-go/pkg/tm"
"github.com/seata/seata-go/pkg/util/log"
Expand Down Expand Up @@ -69,6 +70,10 @@ func initRmClient(cfg *Config) {
onceInitRmClient.Do(func() {
log.Init()
initRemoting(cfg)
rm.InitRm(rm.RmConfig{
ApplicationID: cfg.ApplicationID,
TxServiceGroup: cfg.TxServiceGroup,
})
client.RegisterProcessor()
integration.Init()
tcc.InitTCC()
Expand Down
1 change: 1 addition & 0 deletions pkg/remoting/getty/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (cfg *TransportConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagS
f.DurationVar(&cfg.RPCTmRequestTimeout, prefix+".rpc-tm-request-timeout", 30*time.Second, "TM send request timeout.")
}

// todo refactor config
type SeataConfig struct {
ApplicationID string
TxServiceGroup string
Expand Down
2 changes: 1 addition & 1 deletion pkg/remoting/getty/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ func (c *RpcClient) setSessionConfig(session getty.Session) {
session.SetEventListener(GetGettyClientHandlerInstance())
session.SetReadTimeout(c.gettyConf.SessionConfig.TCPReadTimeout)
session.SetWriteTimeout(c.gettyConf.SessionConfig.TCPWriteTimeout)
session.SetCronPeriod((int)(c.gettyConf.SessionConfig.CronPeriod.Nanoseconds() / 1e6))
session.SetCronPeriod((int)(c.gettyConf.SessionConfig.CronPeriod.Milliseconds()))
session.SetWaitTime(c.gettyConf.SessionConfig.WaitTimeout)
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (f *rmBranchRollbackProcessor) Process(ctx context.Context, rpcMessage mess
log.Errorf("branch rollback error: %s", err.Error())
return err
}
log.Infof("branch rollback success: xid %s, branchID %s, resourceID %s, applicationData %s", xid, branchID, resourceID, applicationData)
log.Infof("branch rollback success: xid %s, branchID %d, resourceID %s, applicationData %s", xid, branchID, resourceID, applicationData)

var (
resultCode message.ResultCode
Expand Down
11 changes: 7 additions & 4 deletions pkg/rm/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

package rm

// Init init seata client
func Init() {
initRmClient()
var rmConfig RmConfig

type RmConfig struct {
ApplicationID string
TxServiceGroup string
}

// InitRmClient init seata rm client
func initRmClient() {
func InitRm(cfg RmConfig) {
rmConfig = cfg
}
5 changes: 2 additions & 3 deletions pkg/rm/rm_remoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ func (r *RMRemoting) LockQuery(param LockQueryParam) (bool, error) {
func (r *RMRemoting) RegisterResource(resource Resource) error {
req := message.RegisterRMRequest{
AbstractIdentifyRequest: message.AbstractIdentifyRequest{
// todo replace with config
Version: "1.5.2",
ApplicationId: "tcc-sample",
TransactionServiceGroup: "my_test_tx_group",
ApplicationId: rmConfig.ApplicationID,
TransactionServiceGroup: rmConfig.TxServiceGroup,
},
ResourceIds: resource.GetResourceId(),
}
Expand Down