A Context carries a deadline, a cancellation signal, and other values across API boundaries.

Hierarchy

Properties

deadline: undefined | Date

returns the time when work done on behalf of this context should be canceled. returns undefined when no deadline is set. Successive calls to Deadline return the same results.

done: ReadChannel<void>

returns a channel that's closed when work done on behalf of this context should be canceled. Successive calls to Done return the same value.

err: undefined | Exception

If done is not yet closed,err is undefined. If done is closed, err is a non-nil error explaining why

isClosed: boolean

If done is not yet closed, isClosed is false. If done is closed, isClosed is true

Methods

  • get() returns the value associated with this context for key or undefined if no value is associated with key. Successive calls to get() with the same key returns the same result.

    Type Parameters

    • T

    Parameters

    Returns undefined | T

  • get() returns the [value,true] associated with this context for key or [undefined, false] if no value is associated with key. Successive calls to get() with the same key returns the same result.

    Type Parameters

    • T

    Parameters

    Returns [undefined, false] | [T, true]

  • Promise returns true after waiting for the number of milliseconds specified by ms, if done before then Promise returns false immediately

    Parameters

    • ms: number

    Returns Promise<boolean>

  • return a Promise wait done closed

    Returns undefined | Promise<void>

  • returns a copy of this with a new Done channel. The returned context's Done channel is closed when the returned copy cancel function is called or when the parent context's Done channel is closed, whichever happens first.

    Returns CancelContext

  • returns a copy of this with a new Done channel. The returned context's Done channel is closed when the returned copy cancel function is called or when the parent context's Done channel is closed, whichever happens first.

    Parameters

    • cancelFunc: true

    Returns [CancelContext, CancelFunc]

  • returns a copy of the this context with the deadline adjusted to be no later than d. If the this's deadline is already earlier than d, withDeadline(d) is semantically equivalent to this. The returned context's Done channel is closed when the deadline expires, when the returned cancel function is called, or when the this context's Done channel is closed, whichever happens first.

    Parameters

    • d: Date

    Returns CancelContext

  • returns a copy of the this context with the deadline adjusted to be no later than d. If the this's deadline is already earlier than d, withDeadline(d) is semantically equivalent to this. The returned context's Done channel is closed when the deadline expires, when the returned cancel function is called, or when the this context's Done channel is closed, whichever happens first.

    Parameters

    • d: Date
    • cancelFunc: true

    Returns [CancelContext, CancelFunc]

Generated using TypeDoc