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

Add support to the core and tuple packages for relationship expiration #2146

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

josephschorr
Copy link
Member

No description provided.

@josephschorr josephschorr requested review from vroldanbet and a team as code owners November 26, 2024 21:27
@github-actions github-actions bot added area/api v1 Affects the v1 API area/datastore Affects the storage system area/dependencies Affects dependencies area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) area/schema Affects the Schema Language area/dispatch Affects dispatching of requests labels Nov 26, 2024
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

See comments - will rereview after that.

@@ -73,7 +73,7 @@ func (ch *Changes[R, K]) AddRelationshipChange(
return err
}

key := tuple.StringWithoutCaveat(rel)
key := tuple.StringWithoutCaveatOrExpiration(rel)
Copy link
Contributor

Choose a reason for hiding this comment

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

WithoutTraits?

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 wanted to be explicit for now; if/when we add more traits, I plan to rename

Comment on lines +157 to +161
for _, rel := range batch.Relationships {
if rel.OptionalExpiresAt != nil {
return nil, fmt.Errorf("expiration time is not currently supported")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this extra defensiveness for the current release?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep!

@@ -71,6 +71,8 @@ func TestEqual(t *testing.T) {
MustParse("document:foo#viewer@user:tom[somecaveat:{\"hi\":{\"yo\":123}}]"),
MustParse("document:foo#viewer@user:tom[somecaveat:{\"hi\":{\"yo\":{\"hey\":true}}, \"hi2\":{\"yo2\":{\"hey2\":false}}}]"),
MustParse("document:foo#viewer@user:tom[somecaveat:{\"hi\":{\"yo\":{\"hey\":true}}, \"hi2\":{\"yo2\":{\"hey2\":[1,2,3]}}}]"),
MustParse("document:foo#viewer@user:tom[expiration:2020-01-01T00:00:00Z]"),
MustParse("document:foo#viewer@user:tom[somecaveat:{\"hi\":\"there\"}][expiration:2020-01-01T00:00:00Z]"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing separate brackets for each trait? I'd be in favor of having them within the same set of brackets and comma-separated like in the first example from slack.

Copy link
Member Author

@josephschorr josephschorr Nov 26, 2024

Choose a reason for hiding this comment

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

Yeah, I felt each bracket made it more readable (and makes it easier to parse)

tstirrat15
tstirrat15 previously approved these changes Nov 27, 2024
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

LGTM

internal/services/v1/experimental.go Show resolved Hide resolved
internal/services/v1/relationships.go Show resolved Hide resolved
pkg/tuple/strings.go Show resolved Hide resolved
pkg/tuple/hashing.go Show resolved Hide resolved
pkg/tuple/parsing_test.go Show resolved Hide resolved
pkg/tuple/parsing.go Outdated Show resolved Hide resolved
pkg/tuple/parsing.go Show resolved Hide resolved
pkg/tuple/core_test.go Outdated Show resolved Hide resolved
@josephschorr josephschorr added this pull request to the merge queue Nov 27, 2024
Merged via the queue into authzed:main with commit 245c85a Nov 27, 2024
22 checks passed
@josephschorr josephschorr deleted the rel-expiration-core branch November 27, 2024 16:00
@github-actions github-actions bot locked and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/api v1 Affects the v1 API area/datastore Affects the storage system area/dependencies Affects dependencies area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants