Skip to content

Commit

Permalink
Ctx -> UnafeCtx
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhengl committed Nov 21, 2024
1 parent 934161c commit 12a12cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions internal/tenant/systemtenant/systemtenant.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Package systemtenant contains function to mark a context as allowed to
// access shards across all tenants. This must only be used for tasks that are
// not request specific.
// Package systemtenant exports UnsafeCtx which allows to access shards across
// all tenants. This must only be used for tasks that are not request specific.
package systemtenant

import (
Expand All @@ -11,9 +10,9 @@ type contextKey int

const systemTenantKey contextKey = iota

// Ctx is a context that allows queries across all tenants. This must only be
// used for tasks that are not user request specific.
var Ctx = context.WithValue(context.Background(), systemTenantKey, systemTenantKey)
// UnsafeCtx is a context that allows queries across all tenants. Don't use this
// for user requests.
var UnsafeCtx = context.WithValue(context.Background(), systemTenantKey, systemTenantKey)

// Is returns true if the context has been marked to allow queries across all
// tenants.
Expand Down
2 changes: 1 addition & 1 deletion internal/tenant/systemtenant/systemtenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ func TestSystemtenantRoundtrip(t *testing.T) {
if Is(context.Background()) {
t.Fatal()
}
require.True(t, Is(Ctx))
require.True(t, Is(UnsafeCtx))
}
2 changes: 1 addition & 1 deletion shards/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ func (s *shardedSearcher) getLoaded() loaded {

func mkRankedShard(s zoekt.Searcher) *rankedShard {
q := query.Const{Value: true}
result, err := s.List(systemtenant.Ctx, &q, nil)
result, err := s.List(systemtenant.UnsafeCtx, &q, nil)
if err != nil {
return &rankedShard{Searcher: s}
}
Expand Down

0 comments on commit 12a12cd

Please sign in to comment.