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

Add Update/Put item output #47

Merged
merged 5 commits into from
Feb 16, 2020
Merged

Conversation

talIguaz
Copy link
Contributor

Create an output for update and put item containing mtime.

@@ -1476,3 +1490,30 @@ func (c *context) stop(reason string, timeout *time.Duration) error {

return nil
}

// parsing the mtime from a header of the form `__mtime_secs==1581605100 and __mtime_nsecs==498349956`
func parseMtimeHeader(response *v3io.Response) (int, int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't ignore errors

updateItemInput.Path,
putItemFunctionName,
updateItemInput.Attributes,
updateItemInput.Condition,
putItemHeaders,
body)

mtimeSecs, mtimeNSecs := parseMtimeHeader(response)
output := &v3io.UpdateItemOutput{MtimeSecs: mtimeSecs, MtimeNSecs: mtimeNSecs}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this "output" variable? Just set .Output to &v3io.UpdateItemOutput{...
Same as in the other place(s)

if err != nil {
return 0, 0
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

else? is this an error?

mtimeParts := strings.Split(expression, "==")
mtimeType := strings.TrimSpace(mtimeParts[0])
if mtimeType == "__mtime_secs" {
mtimeSecsStr := strings.TrimSpace(mtimeParts[1])
Copy link
Contributor

Choose a reason for hiding this comment

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

You're repeating the parse logic here. Please move to a small helper function that returns int, error

@pavius pavius merged commit 3b52a32 into v3io:0.0.x Feb 16, 2020
dinal pushed a commit to dinal/v3io-go that referenced this pull request Feb 28, 2020
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.

2 participants