context

package
v0.0.0-...-c5af384 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2015 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package context provides a Context type to propagate state and cancellation information.

Index

Constants

This section is empty.

Variables

View Source
var ErrCanceled = errors.New("canceled")

ErrCanceled may be returned by code when it receives from a Context.Done channel.

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

A Context is carries state and cancellation information between calls. A nil Context pointer is valid, for now.

func New

func New(params ...Param) *Context

New returns a new Context. Any provided params modify the returned context.

func TODO

func TODO() *Context

TODO returns a dummy context. It's a signal that the caller code is not yet correct, and needs its own context to propagate.

func (*Context) Cancel

func (c *Context) Cancel()

Cancel cancels the context. It is idempotent.

func (*Context) Done

func (c *Context) Done() <-chan struct{}

Done returns a channel that is closed when the Context is canceled or finished.

func (*Context) HTTPClient

func (c *Context) HTTPClient() *http.Client

HTTPClient returns the HTTP Client to use for this context.

func (*Context) IsCanceled

func (c *Context) IsCanceled() bool

IsCanceled reports whether this context has been canceled.

func (*Context) New

func (c *Context) New(params ...Param) *Context

New returns a child context attached to the receiver parent context c. The returned context is done when the parent is done, but the returned child context can be canceled independently without affecting the parent.

type Param

type Param interface {
	// contains filtered or unexported methods
}

A Param modifies a Context as returned by New.

func WithHTTPClient

func WithHTTPClient(cl *http.Client) Param

WithHTTPClient sets the HTTP client as returned by HTTPClient.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL