context

package module
v0.0.0-...-3e35dac Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 3 Imported by: 1

README

Go Report Card GoDoc

context: updatable deadline

golang context.Context implementation with an updatable deadline

usage

package main

import (
	"context"
	"time"
	
	igoctx "github.com/igolaizola/context"
)

func main() {
    ctx, cancel := igoctx.WithDeadline(context.Background())
    defer cancel()
    if err := ctx.SetDeadline(time.Now().Add(1 * time.Second)); err != nil {
    	panic(err)
    }
    <-ctx.Done()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	context.Context
	SetDeadline(t time.Time) error
}

Context is a context.Context implementation with an updatable deadline

func WithDeadline

func WithDeadline(ctx context.Context) (Context, context.CancelFunc)

WithDeadline returns a new context with an updatable deadline

Jump to

Keyboard shortcuts

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