-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into bugfix/nil_storage_close
- Loading branch information
Showing
3 changed files
with
131 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
package api | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
type valuesProxyContext struct { | ||
valueser context.Context | ||
} | ||
|
||
var _ context.Context = (*valuesProxyContext)(nil) | ||
|
||
// Deadline implements interface context.Context. | ||
func (ctx *valuesProxyContext) Deadline() (time.Time, bool) { | ||
return time.Time{}, false | ||
} | ||
|
||
// Done implements interface context.Context. | ||
func (ctx *valuesProxyContext) Done() <-chan struct{} { | ||
return nil | ||
} | ||
|
||
// Err implements interface context.Context. | ||
func (ctx *valuesProxyContext) Err() error { | ||
return nil | ||
} | ||
|
||
// Value implements interface context.Context. | ||
func (ctx *valuesProxyContext) Value(key any) any { | ||
return ctx.valueser.Value(key) | ||
} | ||
|
||
// newValuesProxyContext returns a context without cancellation/deadline signals, | ||
// but with all the values kept as is. | ||
func newValuesProxyContext(ctx context.Context) context.Context { | ||
ctx = &valuesProxyContext{ | ||
valueser: ctx, | ||
} | ||
return ctx | ||
} |