pausable

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPause

func CheckPause(ctx context.Context) error

CheckPause is a convenience function that checks if any context in the chain is pausable and paused

Types

type Context

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

Context wraps a context.Context and allows pausing/resuming operations

func FromContext

func FromContext(ctx context.Context) (*Context, bool)

FromContext retrieves the pausable context from any context in the chain This works even if the context has been wrapped by context.WithCancel, context.WithTimeout, etc.

func NewContext

func NewContext(parent context.Context) *Context

NewContext creates a new pausable context that stores itself in the context chain

func (*Context) CheckPause

func (pc *Context) CheckPause() error

CheckPause blocks if the context is paused until it's resumed or the parent context is canceled

func (*Context) Deadline

func (pc *Context) Deadline() (deadline time.Time, ok bool)

Deadline returns the parent context's deadline

func (*Context) Done

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

Done returns a channel that's closed when the context is canceled or the parent is done

func (*Context) Err

func (pc *Context) Err() error

Err returns the parent context's error

func (*Context) IsPaused

func (pc *Context) IsPaused() bool

IsPaused returns whether the context is currently paused

func (*Context) Pause

func (pc *Context) Pause()

Pause pauses the context - operations should call CheckPause() to respect this

func (*Context) Resume

func (pc *Context) Resume()

Resume resumes the context

func (*Context) Value

func (pc *Context) Value(key interface{}) interface{}

Value returns the parent context's value

Jump to

Keyboard shortcuts

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