// getCancelableContext returns a new cancelable context. For long running requests without timeout, we use cancelable
// context to avoid potential resource leak, although the current implementation shouldn't leak resource.
507413
func (d *kubeDockerClient) getCancelableContext() (context.Context, context.CancelFunc) {
	return context.WithCancel(context.Background())
}
292853
func (ml *MockRouteCountLogger) GetContext(key string) (interface{}, bool) {
	return ml.logger.GetContext(key)
}
598963
func (l *Logger) GetContext(key string) (interface{}, bool) {
	l.globalsL.RLock()
	defer l.globalsL.RUnlock()
	val, ok := l.globals[key]
	return val, ok
}
1273408
func (d *kubeDockerClient) getTimeoutContext() (context.Context, context.CancelFunc) {
	return context.WithTimeout(context.Background(), d.timeout)
}
502721
func GetContext(sp *Spider, req *request.Request) *Context {
	ctx := contextPool.Get().(*Context)
	ctx.spider = sp
	ctx.Request = req
	return ctx
}
86270
func FromContext(ctx context.Context) error {
	e := ctx.Err()
	if e == nil {
		return nil
	}

	if e == context.Canceled {
		return Cancelled(e)
	}
	if e == context.DeadlineExceeded {
		return Deadline(e)
	}
	return Unknown(e)
}
1313508
func (c *CancelCall) Context(ctx context.Context) *CancelCall {
	c.ctx_ = ctx
	return c
}
628035
func AppContext(context *cli.Context) (gocontext.Context, gocontext.CancelFunc) {
	var (
		ctx       = gocontext.Background()
		timeout   = context.GlobalDuration("timeout")
		namespace = context.GlobalString("namespace")
		cancel    gocontext.CancelFunc
	)
	ctx = namespaces.WithNamespace(ctx, namespace)
	if timeout > 0 {
		ctx, cancel = gocontext.WithTimeout(ctx, timeout)
	} else {
		ctx, cancel = gocontext.WithCancel(ctx)
	}
	return ctx, cancel
}
447806
func ContextSleep(ctx context.Context, timeout time.Duration) {
	ctx, cancel := context.WithTimeout(ctx, timeout)
	select {
	case <-ctx.Done():
	}
	cancel()
}
477934
func IsCanceled(err error) bool {
	return isCausedBy(err, func(e error) bool { return e == context.Canceled })
}
17993
func ToContext(ctx context.Context, logger *zap.Logger) context.Context {
	return ctxzap.ToContext(ctx, logger)
}
244942
func (r *ReindexSource) FetchSourceContext(fsc *FetchSourceContext) *ReindexSource {
	r.request = r.request.FetchSourceContext(fsc)
	return r
}
1248289
func (d *DeploymentRequest) GetRequiredContexts() []string {
	if d == nil || d.RequiredContexts == nil {
		return nil
	}
	return *d.RequiredContexts
}
78080
func Context(ctx context.Context) Option {
	return func(o *Options) {
		o.Context = ctx
	}
}
691341
func FromContext(ctx context.Context) *Context {
	c, _ := ctx.Value(contextKey{}).(*Context)
	return c
}
1207247
func (c *Config) getContext() context.Context {
	client := &http.Client{
		Transport: util.NewRoundTripper(log.Get(), c.Client.ExtraHeaders),
	}

	return context.WithValue(context.Background(), oauth2.HTTPClient, client)
}
731887
func (r *Request) WithContext(ctx context.Context) *Request {
	r.Request = r.Request.WithContext(ctx)
	return r
}