summaryrefslogtreecommitdiff
path: root/vendor/github.com/aws/aws-sdk-go-v2/internal/context/context.go
blob: f0c283d3942b61b3a2d7d9fdb14bd1021469e582 (plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package context

import (
	"context"
	"time"

	"github.com/aws/smithy-go/middleware"
)

type s3BackendKey struct{}
type checksumInputAlgorithmKey struct{}
type clockSkew struct{}

const (
	// S3BackendS3Express identifies the S3Express backend
	S3BackendS3Express = "S3Express"
)

// SetS3Backend stores the resolved endpoint backend within the request
// context, which is required for a variety of custom S3 behaviors.
func SetS3Backend(ctx context.Context, typ string) context.Context {
	return middleware.WithStackValue(ctx, s3BackendKey{}, typ)
}

// GetS3Backend retrieves the stored endpoint backend within the context.
func GetS3Backend(ctx context.Context) string {
	v, _ := middleware.GetStackValue(ctx, s3BackendKey{}).(string)
	return v
}

// SetChecksumInputAlgorithm sets the request checksum algorithm on the
// context.
func SetChecksumInputAlgorithm(ctx context.Context, value string) context.Context {
	return middleware.WithStackValue(ctx, checksumInputAlgorithmKey{}, value)
}

// GetChecksumInputAlgorithm returns the checksum algorithm from the context.
func GetChecksumInputAlgorithm(ctx context.Context) string {
	v, _ := middleware.GetStackValue(ctx, checksumInputAlgorithmKey{}).(string)
	return v
}

// SetAttemptSkewContext sets the clock skew value on the context
func SetAttemptSkewContext(ctx context.Context, v time.Duration) context.Context {
	return middleware.WithStackValue(ctx, clockSkew{}, v)
}

// GetAttemptSkewContext gets the clock skew value from the context
func GetAttemptSkewContext(ctx context.Context) time.Duration {
	x, _ := middleware.GetStackValue(ctx, clockSkew{}).(time.Duration)
	return x
}