ctxutil

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 6 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 GetNamedCancel added in v1.3.13

func GetNamedCancel(ctx context.Context, name string) (context.CancelFunc, bool)

func Keep added in v1.3.7

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

func MustCancelNamed added in v1.3.13

func MustCancelNamed(ctx context.Context, name string)

func PipeWithContext added in v1.3.13

func PipeWithContext(ctx context.Context) (*io.PipeReader, *io.PipeWriter)

func Retry

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

func RetryIncrease added in v1.3.13

func RetryIncrease(ctx context.Context, retryPause time.Duration, fn func() error) error

func Sleep added in v1.3.13

func Sleep(ctx context.Context, dur time.Duration) error

func TryCancelNamed added in v1.3.13

func TryCancelNamed(ctx context.Context, name string) bool

func WithCancel2 added in v1.3.8

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

func WithNamedCancel added in v1.3.13

func WithNamedCancel(ctx context.Context, name string) context.Context

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