CustomRoleCacheContext prevents needing to lookup custom roles within the same request lifecycle. Optimizing this to span requests should be done in the future.
(ctx context.Context)
| 29 | // same request lifecycle. Optimizing this to span requests should be done |
| 30 | // in the future. |
| 31 | func CustomRoleCacheContext(ctx context.Context) context.Context { |
| 32 | return context.WithValue(ctx, customRoleCtxKey{}, syncmap.New[string, rbac.Role]()) |
| 33 | } |
| 34 | |
| 35 | func roleCache(ctx context.Context) *syncmap.Map[string, rbac.Role] { |
| 36 | c, ok := ctx.Value(customRoleCtxKey{}).(*syncmap.Map[string, rbac.Role]) |