-
Notifications
You must be signed in to change notification settings - Fork 283
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
optimize: optimise way of init seata #187
Changes from all commits
7f6b6eb
5c73d22
e8d5924
f5e3baf
9e20e1a
b89850a
c3000ff
420879f
3ef38ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
package main | ||
package client | ||
|
||
func main() { | ||
// start seata server | ||
// InitRmClient init seata rm client | ||
func initRmClient() { | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为啥没有实现呢 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm clinet的初始化现在在init方法中全部做完了,暂时没有需要初始化的逻辑 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package client | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/seata/seata-go/pkg/remoting/getty" | ||
) | ||
|
||
var onceInitTmClient sync.Once | ||
|
||
// InitTmClient init seata tm client | ||
func initTmClient() { | ||
onceInitTmClient.Do(func() { | ||
initConfig() | ||
initRemoting() | ||
}) | ||
} | ||
|
||
// todo | ||
// initConfig init config processor | ||
func initConfig() { | ||
} | ||
|
||
// initRemoting init rpc client | ||
func initRemoting() { | ||
getty.InitRpcClient() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package codec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/seata/seata-go/pkg/protocol/message" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGlobalReportRequestCodec(t *testing.T) { | ||
msg := message.GlobalReportRequest{ | ||
AbstractGlobalEndRequest: message.AbstractGlobalEndRequest{ | ||
Xid: "test-transaction-id", | ||
ExtraData: []byte("TestExtraData"), | ||
}, | ||
GlobalStatus: message.GlobalStatusBegin, | ||
} | ||
|
||
codec := GlobalReportRequestCodec{} | ||
bytes := codec.Encode(msg) | ||
msg2 := codec.Decode(bytes) | ||
|
||
assert.Equal(t, msg, msg2) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ type GlobalReportRequest struct { | |
} | ||
|
||
func (req GlobalReportRequest) GetTypeCode() MessageType { | ||
return MessageType_GlobalStatus | ||
return MessageType_GlobalReport | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不太清楚这里的下划线符不符合golang的代码风格 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个后面讨论下,单独提交一个PR,代码中有不少_格式的命名 |
||
} | ||
|
||
type GlobalCommitRequest struct { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,6 @@ | |
|
||
package main | ||
|
||
import ( | ||
_ "github.com/seata/seata-go/pkg/imports" | ||
) | ||
|
||
func main() { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个包名可不可以换成 seataXXX,这样用户在用的时候就会方便点。写出的代码可读性也轻一点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前写过类似的命名,被社区纠正了。你有啥建议吗?