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

Allow non-strings to be used to set ttl field in generic. #2699

Merged
merged 2 commits into from
May 9, 2017

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented May 9, 2017

Fixes #2697

@jefferai jefferai added this to the 0.7.3 milestone May 9, 2017
@jefferai jefferai requested review from calvn and vishalnayak May 9, 2017 16:23
Copy link
Contributor

@calvn calvn left a comment

Choose a reason for hiding this comment

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

LGTM!

b = testPassthroughBackend()
test(b, "lease", false)
test(b, "ttl", false)
test(b, "lease", int64(10), false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we test for passing 10 directly, as opposed to int64(10)?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this ensures that the interface value is the right type. Otherwise this defaults to an int.

if !ok {
ttlInt, ok = rawData["lease"]
}
if ok {
Copy link
Member

Choose a reason for hiding this comment

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

@jefferai Do we not want to do this regardless of ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, if ok isn't true then neither of those fields exist.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see now.

ttlDuration := b.System().DefaultLeaseTTL()
if len(ttl) != 0 {
dur, err := parseutil.ParseDurationSecond(ttl)
ttlInt, ok := rawData["ttl"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, but I interpreted this variable as "TTL integer" when i think it's supposed to be "TTL interface", could you rename it to ttlRaw or something similar?

Copy link
Contributor

@briankassouf briankassouf left a comment

Choose a reason for hiding this comment

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

Other than that one comment LGTM!

@jefferai jefferai merged commit ca61ef7 into master May 9, 2017
@jefferai jefferai deleted the issue-2697 branch May 9, 2017 18:05
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.

4 participants