ctxutil

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(ctx context.Context, prefix string, fn func() error, lateFn func(error)) error

Allows fn to return early on ctx cancel. If fn does not return in time, lateFn will run at the end of fn (async).

func CallsState

func CallsState() string

func Keep added in v1.3.7

func Keep[T any](ps ...*T) *keeper[T]

func Retry

func Retry(ctx context.Context, retryPause time.Duration, prefix string, fn func() error, lateFn func(error)) error

func WithCancel2 added in v1.3.8

func WithCancel2(ctx1, ctx2 context.Context) (context.Context, context.CancelFunc)

Types

type Ctx added in v1.1.0

type Ctx struct {
	Parent *Ctx
	// name/value (short names to avoid usage, still exporting it)
	N string
	V any
}

func (*Ctx) Value added in v1.1.0

func (ctx *Ctx) Value(name string) (any, *Ctx)

func (*Ctx) ValueBool added in v1.1.0

func (ctx *Ctx) ValueBool(name string) bool

func (*Ctx) ValueInt added in v1.1.0

func (ctx *Ctx) ValueInt(name string) int

func (*Ctx) WithValue added in v1.1.0

func (ctx *Ctx) WithValue(name string, value any) *Ctx

Jump to

Keyboard shortcuts

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