Skip to content

Commit

Permalink
Update namespace.FromContext comment (hashicorp#18840)
Browse files Browse the repository at this point in the history
It looks like namespace context caching was removed in
hashicorp#5200
but this comment was left referencing it, which I found confusing
at first glance.
  • Loading branch information
Christopher Swenson committed Feb 13, 2023
1 parent d0b279b commit 063a782
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions helper/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ func RootContext(ctx context.Context) context.Context {
return ContextWithNamespace(ctx, RootNamespace)
}

// This function caches the ns to avoid doing a .Value lookup over and over,
// because it's called a *lot* in the request critical path. .Value is
// concurrency-safe so uses some kind of locking/atomicity, but it should never
// be read before first write, plus we don't believe this will be called from
// different goroutines, so it should be safe.
// FromContext retrieves the namespace from a context, or an error
// if there is no namespace in the context.
func FromContext(ctx context.Context) (*Namespace, error) {
if ctx == nil {
return nil, errors.New("context was nil")
Expand Down

0 comments on commit 063a782

Please sign in to comment.