(ctx context.Context, req *ResolveCheckRequest, mapping *recursiveMapping)
| 162 | } |
| 163 | |
| 164 | func buildRecursiveMapper(ctx context.Context, req *ResolveCheckRequest, mapping *recursiveMapping) (storage.TupleMapper, error) { |
| 165 | var iter storage.TupleIterator |
| 166 | var err error |
| 167 | typesys, _ := typesystem.TypesystemFromContext(ctx) |
| 168 | ds, _ := storage.RelationshipTupleReaderFromContext(ctx) |
| 169 | consistencyOpts := storage.ConsistencyOptions{ |
| 170 | Preference: req.GetConsistency(), |
| 171 | } |
| 172 | |
| 173 | switch mapping.kind { |
| 174 | case storage.UsersetKind: |
| 175 | objectType := req.GetTupleKey().GetObject() |
| 176 | relation := req.GetTupleKey().GetRelation() |
| 177 | iter, err = ds.ReadUsersetTuples(ctx, req.GetStoreID(), storage.ReadUsersetTuplesFilter{ |
| 178 | Object: objectType, |
| 179 | Relation: relation, |
| 180 | AllowedUserTypeRestrictions: mapping.allowedUserTypeRestrictions, |
| 181 | }, storage.ReadUsersetTuplesOptions{Consistency: consistencyOpts}) |
| 182 | case storage.TTUKind: |
| 183 | objectType := req.GetTupleKey().GetObject() |
| 184 | iter, err = ds.Read(ctx, req.GetStoreID(), |
| 185 | storage.ReadFilter{Object: objectType, Relation: mapping.tuplesetRelation, User: ""}, |
| 186 | storage.ReadOptions{Consistency: consistencyOpts}) |
| 187 | default: |
| 188 | return nil, errors.New("unsupported mapper kind") |
| 189 | } |
| 190 | if err != nil { |
| 191 | return nil, err |
| 192 | } |
| 193 | filteredIter := storage.NewConditionsFilteredTupleKeyIterator( |
| 194 | storage.NewFilteredTupleKeyIterator( |
| 195 | storage.NewTupleKeyIteratorFromTupleIterator(iter), |
| 196 | validation.FilterInvalidTuples(typesys), |
| 197 | ), |
| 198 | checkutil.BuildTupleKeyConditionFilter(ctx, req.GetContext(), typesys), |
| 199 | ) |
| 200 | return storage.WrapIterator(mapping.kind, filteredIter), nil |
| 201 | } |
| 202 | |
| 203 | func (c *LocalChecker) recursiveMatchUserUserset(ctx context.Context, req *ResolveCheckRequest, mapping *recursiveMapping, currentLevelFromObject *hashset.Set, usersetFromUser *hashset.Set) (*ResolveCheckResponse, error) { |
| 204 | ctx, span := tracer.Start(ctx, "recursiveMatchUserUserset", trace.WithAttributes( |
searching dependent graphs…