]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | // +build !go1.7 |
2 | ||
3 | package aws | |
4 | ||
5 | import "time" | |
6 | ||
15c0b25d AP |
7 | // An emptyCtx is a copy of the Go 1.7 context.emptyCtx type. This is copied to |
8 | // provide a 1.6 and 1.5 safe version of context that is compatible with Go | |
9 | // 1.7's Context. | |
bae9f6d2 JC |
10 | // |
11 | // An emptyCtx is never canceled, has no values, and has no deadline. It is not | |
12 | // struct{}, since vars of this type must have distinct addresses. | |
13 | type emptyCtx int | |
14 | ||
15 | func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { | |
16 | return | |
17 | } | |
18 | ||
19 | func (*emptyCtx) Done() <-chan struct{} { | |
20 | return nil | |
21 | } | |
22 | ||
23 | func (*emptyCtx) Err() error { | |
24 | return nil | |
25 | } | |
26 | ||
27 | func (*emptyCtx) Value(key interface{}) interface{} { | |
28 | return nil | |
29 | } | |
30 | ||
31 | func (e *emptyCtx) String() string { | |
32 | switch e { | |
33 | case backgroundCtx: | |
34 | return "aws.BackgroundContext" | |
35 | } | |
36 | return "unknown empty Context" | |
37 | } | |
38 | ||
39 | var ( | |
40 | backgroundCtx = new(emptyCtx) | |
41 | ) | |
107c1cdb ND |
42 | |
43 | // BackgroundContext returns a context that will never be canceled, has no | |
44 | // values, and no deadline. This context is used by the SDK to provide | |
45 | // backwards compatibility with non-context API operations and functionality. | |
46 | // | |
47 | // Go 1.6 and before: | |
48 | // This context function is equivalent to context.Background in the Go stdlib. | |
49 | // | |
50 | // Go 1.7 and later: | |
51 | // The context returned will be the value returned by context.Background() | |
52 | // | |
53 | // See https://golang.org/pkg/context for more information on Contexts. | |
54 | func BackgroundContext() Context { | |
55 | return backgroundCtx | |
56 | } |