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

syntax: Datetime, URI, CID, TID #360

Merged
merged 10 commits into from
Oct 12, 2023
Merged

syntax: Datetime, URI, CID, TID #360

merged 10 commits into from
Oct 12, 2023

Conversation

bnewbold
Copy link
Collaborator

@bnewbold bnewbold commented Oct 2, 2023

More of these parse helpers.

Datetime is the main thing here, with a bunch of test cases.

TID is also helpful, and a bunch of little interop issues came up when implementing this.

The CID and URI ones are a bit weird. URIs aren't very well spec'd in a general/abstract sense, and for CIDs we already have go-cid which is what would normally be used. But I think it is good to have string-only validation that ensures exact pass-through, and can be used as a type signature.


Questions for review:

  • the TID clock generator really isn't a "syntax" thing. I slipped it in b/c it is only a few lines of code and stdlib (no external deps). but maybe it should live elsewhere?

@bnewbold bnewbold requested a review from ericvolp12 October 2, 2023 19:10
}

// Constructs a new TID from a UNIX timestamp (in milliseconds) and clock ID value.
func NewTID(unixMilis int64, clockId uint) TID {
Copy link
Collaborator

@ericvolp12 ericvolp12 Oct 4, 2023

Choose a reason for hiding this comment

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

I wonder if this should take a time.Time and extract the milliseconds for us. Thinking about the calling conventions here and Go doesn't really deal with millisecond time often.

Also is this Microseconds or milliseconds? The usage below implies this is Microseconds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, good catch on the millis/micros, I fixed the behavior but didn't remember to update the variable names (or a test call).

I added NewTIDFromTime. I'd be open to renaming and have NewTID take a time and rename the existing to NewTIDFromUnixMicros (eg). I think it is fine either way.

Copy link
Collaborator

@ericvolp12 ericvolp12 left a comment

Choose a reason for hiding this comment

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

Sure, there may be some iteration as we start using these but looks good!

@bnewbold bnewbold merged commit a135de9 into main Oct 12, 2023
6 checks passed
@bnewbold bnewbold deleted the bnewbold/more-syntax branch October 12, 2023 00:29
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