-
Notifications
You must be signed in to change notification settings - Fork 287
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
feat: undolog add decompressor func #457
Conversation
init github actions
add apache license
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #457 +/- ##
==========================================
- Coverage 39.05% 38.33% -0.72%
==========================================
Files 144 150 +6
Lines 9120 10011 +891
==========================================
+ Hits 3562 3838 +276
- Misses 5264 5855 +591
- Partials 294 318 +24
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
* 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 |
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.
这个文件不要
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.
这个暂时好像不能删,项目编译的时候没有执行go generate,导致CI通过不了。
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.
这个暂时好像不能删,项目编译的时候没有执行go generate,导致CI通过不了。
这个文件的作用是来干嘛的呀
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.
用于获取常量的字符串
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.
用于获取常量的字符串
为啥会影响CI呢?看看报啥错,挺奇怪
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.
这个文件看看可以删除了吗
pkg/compressor/deflate_compress.go
Outdated
|
||
"github.com/seata/seata-go/pkg/util/log" | ||
) | ||
|
||
type DeflateCompress struct{} | ||
|
||
var ( | ||
deflateOnce sync.Once |
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.
所有的单例都去了吧,每次返回一个新对象
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.
done
@@ -17,21 +17,6 @@ | |||
|
|||
package compressor | |||
|
|||
type CompressorType int8 |
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.
这个看看是否可以直接写在这里
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.
感觉可能还是放在compress_type 文件一起好点,比较内聚一点。
// UndoLogId The constant undo_log column name xid | ||
// this field is not use in mysql | ||
UndoLogId = "id" | ||
|
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.
这些变量如果没用到,就删了吧
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.
done
@@ -213,7 +215,7 @@ func (m *BaseUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, con | |||
|
|||
parseContext := make(map[string]string, 0) | |||
parseContext[serializerKey] = "jackson" | |||
parseContext[compressorTypeKey] = "NONE" | |||
parseContext[compressorTypeKey] = compressor.CompressorNone.String() |
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.
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.
看代码seata-go这里默认是不压缩,应该没做这一步。
@@ -480,16 +494,30 @@ func (m *BaseUndoLogManager) DecodeMap(str string) map[string]string { | |||
return res | |||
} | |||
|
|||
func (m *BaseUndoLogManager) UnmarshalContext(undoContext []byte) (map[string]string, error) { | |||
res := make(map[string]string) |
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.
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.
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.
所以这里用 unmarshal 是和存储一一对应的,应该没啥问题。
testdata/undo_test.go
Outdated
testUndoLog := func() { | ||
manager := mysql.NewUndoLogManager() | ||
|
||
db, err := sql.Open(sql2.SeataATMySQLDriver, "root:12345678@tcp(127.0.0.1:3306)/seata_client?multiStatements=true") |
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.
数据库操作应该是可以 Mock 的,另外这个测试文件放在 pkg/datasource/sql/undo/base 下比较合适
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.
放在这里会有循环引用问题,这个文件也可以先删了
# By default we only accept connections from localhost | ||
bind-address = 0.0.0.0 | ||
# Disabling symbolic-links is recommended to prevent assorted security risks | ||
symbolic-links=0 |
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.
缺少换行符
- ./mysql:/docker-entrypoint-initdb.d | ||
- ./mysql/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf | ||
ports: | ||
- "3306:3306" |
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.
这个文件应该拆一个 pr
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.
应该误提交了,我回退一下
sleep 5 | ||
curl http://127.0.0.1:7091 | ||
sleep 10 | ||
|
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.
同上
`ext` varchar(100) DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
KEY `idx_unionkey` (`xid`,`branch_id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
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.
同上
* 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 |
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.
用于获取常量的字符串
为啥会影响CI呢?看看报啥错,挺奇怪
var compressor map[string]CompressorType | ||
|
||
func GetByName(name string) CompressorType { | ||
if compressor == nil { |
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.
改为switch...case,每次返回一个新的对象,这样就不要用这个map了
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.
嗯嗯,请教一下为何改为 switch case,感觉这里实现问题不大。
pkg/compressor/zstd_compress.go
Outdated
@@ -23,6 +23,10 @@ import ( | |||
|
|||
type Zstd struct{} | |||
|
|||
func NewZstd() *Zstd { |
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.
如果new没有参数,可以不用写New函数?
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.
嗯,感觉还是有好一点,这能够收敛一下,后期也好维护。
* 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 |
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.
这个文件看看可以删除了吗
@@ -354,7 +368,7 @@ func (m *BaseUndoLogManager) insertUndoLogWithGlobalFinished(ctx context.Context | |||
// todo use config to replace | |||
parseContext := make(map[string]string, 0) | |||
parseContext[serializerKey] = "jackson" | |||
parseContext[compressorTypeKey] = "NONE" | |||
parseContext[compressorTypeKey] = compressor.CompressorNone.String() |
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.
这里能读取下配置文件吗
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.
pkg/compressor/compressor_type.go
Outdated
CompressorSevenz | ||
CompressorBzip2 | ||
CompressorLz4 | ||
CompressorDefault |
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.
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.
done
pkg/compressor/compressor_factory.go
Outdated
var compressorFactory map[string]Compressor | ||
|
||
func (c CompressorType) GetCompressor() Compressor { | ||
if compressorFactory == nil { |
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.
switch
不用单例模式
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.
done
pkg/compressor/bzip2_compress.go
Outdated
@@ -27,6 +27,10 @@ import ( | |||
type Bzip2 struct { | |||
} | |||
|
|||
func NewBizp2() *Bzip2 { |
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.
没有参数不用New
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.
done
type CompressorType int8 | ||
|
||
const ( | ||
CompressorNone CompressorType = iota |
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.
加一个单测
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.
done
|
||
var _CompressorType_index = [...]uint8{0, 14, 28, 41, 57, 72, 85, 102, 116, 133, 147} | ||
|
||
func (i CompressorType) String() string { |
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.
手动写String函数
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.
done
@@ -213,7 +215,7 @@ func (m *BaseUndoLogManager) FlushUndoLog(tranCtx *types.TransactionContext, con | |||
|
|||
parseContext := make(map[string]string, 0) | |||
parseContext[serializerKey] = "jackson" | |||
parseContext[compressorTypeKey] = "NONE" | |||
parseContext[compressorTypeKey] = compressor.CompressorNone.String() |
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.
加个todo
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.
done
What this PR does:
add undo log decompressor func
Which issue(s) this PR fixes:
none
Fixes #449
Special notes for your reviewer:
Does this PR introduce a user-facing change?: