-
Notifications
You must be signed in to change notification settings - Fork 115
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
Parse protobuf with custom parser #262
base: master
Are you sure you want to change the base?
Conversation
ke.like seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
log_store.go
Outdated
return r, nil | ||
} | ||
|
||
func decodeVarInt32(data []byte, pos, rawSize int) ([]int, error) { |
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.
这里感觉可以直接返回 (int length, int pos, err error) 就好了
model.go
Outdated
|
||
type FastLog struct { | ||
Time uint32 | ||
TimeNsPart uint32 |
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.
这里是否需要考虑下可选字段,是否能把 0 值当做不存在
Topic string | ||
} | ||
|
||
type PullLogsResponse struct { |
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.
这个感觉可以复用之前的逻辑, (FastLogGroupList, PullLogMeta, error)
这样后面维护起来,加字段会比较方便一点
log_store.go
Outdated
} | ||
} | ||
if pos != rawSize { | ||
return nil, errors.New("unable to parse pos " + strconv.FormatInt(int64(pos), 10) + " rawSize " + strconv.FormatInt(int64(rawSize), 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.
这里感觉可以简化为
return nil, fmt.Errorf("unable to parse pos %d rawSize %d", pos, rawSize)
log_store.go
Outdated
} | ||
} | ||
if pos != endOffset { | ||
return nil, errors.New("unable to parse pos " + strconv.FormatInt(int64(pos), 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.
这里感觉可以简化一下
return nil, fmt.Errorf("unable to parse pos %d", pos)
@@ -586,6 +587,300 @@ func (s *LogStore) PullLogsWithQuery(plr *PullLogRequest) (gl *LogGroupList, plm | |||
return | |||
} | |||
|
|||
func (s *LogStore) PullLogsV3(plr *PullLogRequest) (r *PullLogsResponse, err error) { |
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.
感觉可以直接复用 plm,后面修改时也简单一点,返回三个值, logs , plm, err
log_store.go
Outdated
mode = values[1] & 0x7 | ||
index = values[1] >> 3 | ||
pos = values[2] | ||
if mode == 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.
这里也可以用 switch
log_store.go
Outdated
return nil, err | ||
} | ||
f.Logs = append(f.Logs, log) | ||
break |
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 的 switch 可以省略 break
No description provided.