openfga / api

Protocol Buffers used by OpenFGA
Apache License 2.0
19 stars 14 forks source link

chore: contextual tuples use WriteRequestTupleKey #101

Closed rhamzeh closed 1 year ago

rhamzeh commented 1 year ago

Description

Considering that Contextual Tuples act like tuples that have been written, it makes sense that they use WriteRequestTupleKey.

Opening up the PR for conversations and thoughts

References

Review Checklist

jon-whit commented 1 year ago

Contextual tuples just augment the tuples in the database. They only differ in that they are provided at request-time. When we handle a contextual tuple key we pass it straight through and yield it as though it was any other TupleKey from the database. Consequently, if we change this to a WriteRequestTupleKey then we'll have to translate each and every contextual tuple to/from a TupleKey in critical code paths dealing with the TupleKey logic (e.g. core Check and ListObjects paths). For that reason, it makes sense to me to have them represented as a TupleKey (e.g. the same thing the storage layer is returning). This avoids conversions in critical code paths and overloading the struct in various places it is used.