context.go 536 B

12345678910111213141516171819202122
  1. package aws
  2. import (
  3. "context"
  4. "github.com/ks3sdklib/aws-sdk-go/internal/apierr"
  5. )
  6. type Context = context.Context
  7. // SetContext adds a Context to the current request that can be used to cancel
  8. func (r *Request) SetContext(ctx Context) {
  9. if ctx == nil {
  10. r.Error = apierr.New("InvalidParameter", "context cannot be nil", nil)
  11. }
  12. r.context = ctx
  13. r.HTTPRequest = r.HTTPRequest.WithContext(ctx)
  14. }
  15. // BackgroundContext returns a context that will never be canceled
  16. func BackgroundContext() Context {
  17. return context.Background()
  18. }