spicedb
spicedb copied to clipboard
Optionally return status on WriteRelationships
This PR is part of a proof of concept for https://github.com/authzed/spicedb/issues/1903.
It temporarily uses a replace statement in go.mod to use the files generated in https://github.com/benvernier-sc/authzed-go/tree/write_relationships_status from https://github.com/authzed/api/pull/106.
It defines a new core protobuf message RelationTupleUpdateStatus that corresponds to the RelationshipUpdateStatus from the API protobuf.
It then updates the signature of ReadWriteTransaction.WriteRelationships from
type ReadWriteTransaction interface {
// [...]
WriteRelationships(ctx context.Context, mutations []*core.RelationTupleUpdate) error
// [...]
}
to
type ReadWriteTransaction interface {
// [...]
WriteRelationships(ctx context.Context, mutations []*core.RelationTupleUpdate, returnStatus bool) ([]*core.RelationTupleUpdateStatus, error)
// [...]
}
This allows to specify whether the store should return the status of the operations or not, and adds a return field with said statuses that are only guaranteed to be populated if returnStatus was true.
All the usages of WriteRelationships store method were updated to ensure the code would still compile. The WriteRelationships gRPC handler was updated to actually pass the WithStatus option from the request and use the returned statuses.
So far only the Postgres implementation has been updated to honor the new options. All scenarios have been tested locally, but no automated tests have been written so far.
CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.
I have read the CLA Document and I hereby sign the CLA
You can retrigger this bot by commenting recheck in this Pull Request
@benvernier-sc Decided this approach didn't work?