summaryrefslogtreecommitdiff
path: root/vendor/github.com/authzed/spicedb/internal/namespace/annotate.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
committermo khan <mo@mokhan.ca>2025-07-22 17:35:49 -0600
commit20ef0d92694465ac86b550df139e8366a0a2b4fa (patch)
tree3f14589e1ce6eb9306a3af31c3a1f9e1af5ed637 /vendor/github.com/authzed/spicedb/internal/namespace/annotate.go
parent44e0d272c040cdc53a98b9f1dc58ae7da67752e6 (diff)
feat: connect to spicedb
Diffstat (limited to 'vendor/github.com/authzed/spicedb/internal/namespace/annotate.go')
-rw-r--r--vendor/github.com/authzed/spicedb/internal/namespace/annotate.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/authzed/spicedb/internal/namespace/annotate.go b/vendor/github.com/authzed/spicedb/internal/namespace/annotate.go
new file mode 100644
index 0000000..d85edff
--- /dev/null
+++ b/vendor/github.com/authzed/spicedb/internal/namespace/annotate.go
@@ -0,0 +1,29 @@
+package namespace
+
+import "github.com/authzed/spicedb/pkg/schema"
+
+// AnnotateNamespace annotates the namespace in the type system with computed aliasing and cache key
+// metadata for more efficient dispatching.
+func AnnotateNamespace(def *schema.ValidatedDefinition) error {
+ aliases, aerr := computePermissionAliases(def)
+ if aerr != nil {
+ return aerr
+ }
+
+ cacheKeys, cerr := computeCanonicalCacheKeys(def, aliases)
+ if cerr != nil {
+ return cerr
+ }
+
+ for _, rel := range def.Namespace().Relation {
+ if alias, ok := aliases[rel.Name]; ok {
+ rel.AliasingRelation = alias
+ }
+
+ if cacheKey, ok := cacheKeys[rel.Name]; ok {
+ rel.CanonicalCacheKey = cacheKey
+ }
+ }
+
+ return nil
+}