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

ulid for instance id #304

Merged
merged 9 commits into from
Apr 7, 2020
Merged

ulid for instance id #304

merged 9 commits into from
Apr 7, 2020

Conversation

asutula
Copy link
Member

@asutula asutula commented Apr 6, 2020

Pretty simple change since we're allowing clients to use any string id if they want.

closes #280

@asutula asutula self-assigned this Apr 6, 2020
core/db/db.go Show resolved Hide resolved
return len(instanceID) > 0
// _, err := uuid.Parse(instanceID)
// return err == nil
Copy link
Member Author

Choose a reason for hiding this comment

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

We can always add more to this in the future, but this is the only check needed for now since we're allowing clients to specify any string as an id.

db/collection.go Outdated
partial := &struct{ ID *string }{}
if err := json.Unmarshal(t, partial); err != nil {
log.Fatalf("error when unmarshaling json instance: %v", err)
return core.EmptyInstanceID, err
Copy link
Member Author

Choose a reason for hiding this comment

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

log.Fatal seems strange to me. I'm not sure why we'd ever want to actually just kill the process when there is an error we can return to the caller. I made this change here since I was working around/in this code, but this log.Fatal is used other places as well. If there is a good reason to revert this, let me know.

Copy link
Member

Choose a reason for hiding this comment

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

There are cases where fatal makes sense. For example, "I've encountered an error that indicates a fatal flaw on logic and I should not be used anymore". There are a number of places where fatal is used like that in here. This one around getting the instance ID could be like that. The system allowed the ID to enter, if it can't get it back out, something bad happened that can't be recovered from. It's nice to have a distinction in the code the separates these kinds of things. But, I'm not super partial to one direction for this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

In those cases where you're saying log.Fatal is the way to go, what is that experience like on the user/client end?

For the sake of simplicity, I'll change this one back.

Copy link
Member

Choose a reason for hiding this comment

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

It would kill their daemon, hopefully they would report the fatal bug.

@asutula asutula marked this pull request as ready for review April 6, 2020 16:43
@asutula
Copy link
Member Author

asutula commented Apr 6, 2020

Not sure what's up with the tests. There is a folder sync test failing because the client trees aren't equal, but they look perfectly equal in the log output. And it passes for me locally 😞

Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Copy link
Member

@sanderpick sanderpick left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Aaron Sutula <[email protected]>
This reverts commit f3a8c66.

Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
Signed-off-by: Aaron Sutula <[email protected]>
@asutula asutula merged commit cca9fab into master Apr 7, 2020
@asutula asutula deleted the asutula/ulid-ids branch April 7, 2020 00:13
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.

Determine instanceID policy
2 participants