-
Notifications
You must be signed in to change notification settings - Fork 4
/
reset.go
38 lines (31 loc) · 821 Bytes
/
reset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package onecontext
import (
"context"
"time"
)
// ResetValuesContext holds the logic reset the values of a context.
type ResetValuesContext struct {
ctx context.Context
}
// ResetValues reset the values of a context.
func ResetValues(ctx context.Context) *ResetValuesContext {
return &ResetValuesContext{
ctx: ctx,
}
}
// Deadline returns the original context deadline.
func (c *ResetValuesContext) Deadline() (time.Time, bool) {
return c.ctx.Deadline()
}
// Done returns the original done channel.
func (c *ResetValuesContext) Done() <-chan struct{} {
return c.ctx.Done()
}
// Err returns the original context error.
func (c *ResetValuesContext) Err() error {
return c.ctx.Err()
}
// Value returns nil regardless of the key.
func (c *ResetValuesContext) Value(_ interface{}) interface{} {
return nil
}