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

Switch To Human Readable Time Values #43

Open
bonedaddy opened this issue Feb 24, 2020 · 6 comments
Open

Switch To Human Readable Time Values #43

bonedaddy opened this issue Feb 24, 2020 · 6 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request v4 issue related to v4 release
Milestone

Comments

@bonedaddy
Copy link
Collaborator

  • Use human-readable time values in places where we rely on time.Duration
@bonedaddy bonedaddy added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 24, 2020
@bonedaddy bonedaddy self-assigned this Feb 24, 2020
@bonedaddy bonedaddy mentioned this issue Feb 24, 2020
@xiegeo
Copy link
Contributor

xiegeo commented Feb 24, 2020

What form will this take? I don't the data defined over the wire needs to change, just how it is displayed.

@bonedaddy
Copy link
Collaborator Author

Replace the int32 in the protocol buffer messages with a string value and use valid time.Duration strings like 1h, 1m, etc... that way we can do a time.ParseDuration.

Part of the issue with using time.ParseDuration before creating the message, and keeping the wire type as int32 is that time.Duration is technically a int64 value, but if the protocol buffer messages need to be used on or sent from 32bit devices to 64bit devices, and vice-versa, there might be some data loss.

By using the string type, it makes it easy since 32-bit and 64-bit devices can interchangeably deal with 1h and not suffer any loss of data due to encoding like big/little edian.

@xiegeo
Copy link
Contributor

xiegeo commented Feb 25, 2020

I agree the wire type should not be int32, but the downside to using time.ParseDuration is that it may not supported in other languages.

I think we can either switch to int64 or use google.protobuf.Duration.

Personally, I also like how Obj-C does duration with seconds in a float64.

@bonedaddy
Copy link
Collaborator Author

bonedaddy commented Feb 25, 2020

We actually aren't using time.Duration directly we're using the "semantics" which will work in every language because it's a string. So if someone wants to specify a 1hr timeout, they would simply give "1h".

Your link looks really interesting and cross-language friendly, I'll check that out.

@xiegeo
Copy link
Contributor

xiegeo commented Feb 25, 2020

If nothing else needs to read the value programically. Then that's a good idea.

@bonedaddy
Copy link
Collaborator Author

If nothing else needs to read the value programically. Then that's a good idea.

The only "thing" that should be reading the value programatically is TemporalX, which since it's Golang can handle the time conversion.

@bonedaddy bonedaddy added the v4 issue related to v4 release label Apr 10, 2020
@bonedaddy bonedaddy added this to the v4 milestone Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request v4 issue related to v4 release
Projects
None yet
Development

No branches or pull requests

2 participants