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

Replace CreateTags with SetTags #33

Closed
wants to merge 2 commits into from
Closed

Conversation

unmultimedio
Copy link
Member

An alternative to #32.

For tags most of the times we don't need two different RPCs, and for sync we always override/move the current tag position, or just create it if it doesn't exist.

In the case we ever need to create-only or move-only, the client can use the existing GetTag RPC first.

// - If a Commit is referenced, Tags are set for that Commit.
// - If a Tag is referenced, Tags are set for the Commit that this Tag references.
// - If a VCSCommit is referenced, Tags are set for the Commit that this VCSCommit references.
// - Is a Branch is referenced, Tags are set for the Commit that this Branch references.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// - Is a Branch is referenced, Tags are set for the Commit that this Branch references.
// - Is a Branch is referenced, Tags are set for the latest Commit on the Branch this references.

Copy link
Contributor

@saquibmian saquibmian left a comment

Choose a reason for hiding this comment

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

I like the use of ResourceRef, even though it's a little strange when used with a Tag reference.

The only caveat with SetTags is that it's impossible to atomically perform a Create operation.

(buf.validate.field).required = true,
(buf.validate.field).string.max_len = 250
];
// The id of the Commit associated with the Tag.
Copy link
Member

Choose a reason for hiding this comment

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

How can you create a commit without a commit_id to reference? Every Tag has a commit id.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the commit would be resolved by the passed ResourceRef. This was motivated mainly by Buf Sync in which we have map[git.Hash][]tags.

@@ -92,31 +91,36 @@ message ListTagsResponse {
repeated Tag tags = 2;
}

message CreateTagsRequest {
// An individual request to create a Tag.
message SetTagsRequest {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just UpdateTags, in the same style as other RPCs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because semantically Update infers that the Tag existed before, I think? This RPC creates or moves the tag.

Copy link
Member

Choose a reason for hiding this comment

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

CreateOrUpdateTags then

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea behind this was that we don't care if it exists or not, just put it here. Without this, the flow is

  1. GetTags
  2. If Tag doesn't exist, call CreateTag; otherwise call UpdateTags.

I'm fine with either approach, especially because sync will already call GetTags (to only sync tags that have changed).

Copy link
Member

Choose a reason for hiding this comment

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

Are there any real downsides to the non-atomic approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we have:

  • Create create a tag that previously didn't exist
  • CreateOrUpdate creates any tags that previously didn't exist, updates any that previously existed

Then I'm happy. I think Create needs to stay because it's impossible to say "create this tag and I want to be sure I'm not moving the tag and potentially breaking someone".

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm cool either way. I'll close this one in favor of #32 then, and comment there.

@bufdev bufdev mentioned this pull request Nov 14, 2023
@unmultimedio
Copy link
Member Author

Closing in favor of #32 to keep atomic version: Create RPC.

@nicksnyder nicksnyder deleted the jfigueroa/set-tags branch December 26, 2023 16:27
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.

3 participants