-
Notifications
You must be signed in to change notification settings - Fork 282
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
Optionally return operation statuses on WriteRelationships #1903
Comments
@josephschorr I did a quick PoC for this:
Let me know your thoughts, if you're happy with the approach I can extend the implementation to cover the other datastores and actually raise a PR for the change. |
@benvernier-sc Seems reasonable at first glance, although we'd need to clean up a bit the conditionals used around whether to add the I did a quick check through the other datastores:
|
Did you have something specific in mind? The way I could see to clean it up would be to do something like columnsToReturn := []string{
colNamespace,
colObjectID,
colRelation,
colUsersetNamespace,
colUsersetObjectID,
colUsersetRelation,
}
if returnStatus {
columnsToReturn = append(columnsToReturn,
colCaveatContextName,
colCaveatContext,
)
}
builder := deleteTuple.
Where(deleteClauses).
Suffix(fmt.Sprintf("RETURNING %s", strings.Join(",", columnsToReturn)))
From a quick look, it does seem like it's going to be hard to do in Spanner with the current |
Problem Statement
The SpiceDB docs cover a Two writes & commits scenario to do dual writes between an existing system and SpiceDB. Those docs suggest performing a
WriteRelationships
call as part of the primary write path for the data, then performing aDeleteRelationships
request if a rollback if necessary.The issue is that if I had a relationship that already existed, I performed a
WriteRelationships
request with aTOUCH
operation on that existing relationship (which would have been a no-op internally) then want to rollback my operation, callingDeleteRelationships
would actually leave my system in a different state than what it was in before I started the operation.Similarly, if one of the operations of my
WriteRelationships
request was aDELETE
operation but the relationship didn't actually exist in SpiceDB, I do not want to create the relationship on rollback as once again this would leave the system in a different state.Solution Brainstorm
When making a call to
WriteRelationships
(with either a single or multiple updates), there are cases where it would be useful to be able to get what the status of each operation was in the response.In particular, knowing whether a
TOUCH
operation actually created a relationship or if it was a no-op, and knowing whether aDELETE
operation actually deleted a relationship or if it was a no-op.I acknowledge that systematically returning that information might come at a performance cost that existing use cases that don't need this information might not be comfortable with, so this could be an option set on the request to specify whether the status breakdown should be returned.
The text was updated successfully, but these errors were encountered: