RelationshipTupleReader is an interface that defines the set of methods required to read relationship tuples from a data store.
| 150 | // RelationshipTupleReader is an interface that defines the set of |
| 151 | // methods required to read relationship tuples from a data store. |
| 152 | type RelationshipTupleReader interface { |
| 153 | // Read the set of tuples associated with `store` and `tupleKey`, which may be nil or partially filled. If nil, |
| 154 | // Read will return an iterator over all the tuples in the given `store`. If the `tupleKey` is partially filled, |
| 155 | // it will return an iterator over those tuples which match the `tupleKey`. Note that at least one of `Object` |
| 156 | // or `User` (or both), must be specified in this case. |
| 157 | // |
| 158 | // The caller must be careful to close the [TupleIterator], either by consuming the entire iterator or by closing it. |
| 159 | // There is NO guarantee on the order of the tuples returned on the iterator. |
| 160 | Read(ctx context.Context, store string, filter ReadFilter, options ReadOptions) (TupleIterator, error) |
| 161 | |
| 162 | // ReadPage functions similarly to Read but includes support for pagination. It takes |
| 163 | // mandatory ReadPageOptions options. PageSize will always be greater than zero. |
| 164 | // It returns a slice of tuples along with a continuation token. This token can be used for retrieving subsequent pages of data. |
| 165 | // There is NO guarantee on the order of the tuples in one page. |
| 166 | ReadPage(ctx context.Context, store string, filter ReadFilter, options ReadPageOptions) ([]*openfgav1.Tuple, string, error) |
| 167 | |
| 168 | // ReadUserTuple tries to return one tuple that matches the provided key exactly. |
| 169 | // If none is found, it must return [ErrNotFound]. |
| 170 | ReadUserTuple( |
| 171 | ctx context.Context, |
| 172 | store string, |
| 173 | filter ReadUserTupleFilter, |
| 174 | options ReadUserTupleOptions, |
| 175 | ) (*openfgav1.Tuple, error) |
| 176 | |
| 177 | // ReadUsersetTuples returns all userset tuples for a specified object and relation. |
| 178 | // For example, given the following relationship tuples: |
| 179 | // document:doc1, viewer, user:* |
| 180 | // document:doc1, viewer, group:eng#member |
| 181 | // and the filter |
| 182 | // object=document:1, relation=viewer, allowedTypesForUser=[group#member] |
| 183 | // this method would return the tuple (document:doc1, viewer, group:eng#member) |
| 184 | // If allowedTypesForUser is empty, both tuples would be returned. |
| 185 | // There is NO guarantee on the order returned on the iterator. |
| 186 | ReadUsersetTuples( |
| 187 | ctx context.Context, |
| 188 | store string, |
| 189 | filter ReadUsersetTuplesFilter, |
| 190 | options ReadUsersetTuplesOptions, |
| 191 | ) (TupleIterator, error) |
| 192 | |
| 193 | // ReadStartingWithUser performs a reverse read of relationship tuples starting at one or |
| 194 | // more user(s) or userset(s) and filtered by object type and relation and possibly a list of object IDs. |
| 195 | // |
| 196 | // For example, given the following relationship tuples: |
| 197 | // document:doc1, viewer, user:jon |
| 198 | // document:doc2, viewer, group:eng#member |
| 199 | // document:doc3, editor, user:jon |
| 200 | // document:doc4, viewer, group:eng#member |
| 201 | // |
| 202 | // ReadStartingWithUser for ['user:jon', 'group:eng#member'] filtered by 'document#viewer' |
| 203 | // and 'document:doc1, document:doc2' would |
| 204 | // return ['document:doc1#viewer@user:jon', 'document:doc2#viewer@group:eng#member']. |
| 205 | // If ReadStartingWithUserOptions.WithResultsSortedAscending bool is enabled, the tuples returned must be sorted by one or more fields in them. |
| 206 | ReadStartingWithUser( |
| 207 | ctx context.Context, |
| 208 | store string, |
| 209 | filter ReadStartingWithUserFilter, |
no outgoing calls
no test coverage detected
searching dependent graphs…