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

Parse protobuf with custom parser #262

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

liketic
Copy link
Collaborator

@liketic liketic commented Apr 15, 2024

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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) {
Copy link
Collaborator

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
Copy link
Collaborator

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 {
Copy link
Collaborator

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))
Copy link
Collaborator

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))
Copy link
Collaborator

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) {
Copy link
Collaborator

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 {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go 的 switch 可以省略 break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants