lifetime

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package lifetime ties the operations an Environment runs to the Environment's own life, so Close can stop them and wait for them.

A process is tracked by the provider and ended by name. A transfer has no handle the caller holds, and it watched only the caller's context: Close returned while one ran on, finishing after it on some providers and failing as a retryable transport fault on another. An operation entered through a Lifetime runs on a context Close cancels, and Close does not return until every one of them has.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ended

func Ended(ctx context.Context) bool

Ended reports whether ctx, from Enter, ended because the Environment closed rather than because the caller stopped.

Types

type Lifetime

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

Lifetime is the life of one Environment. The zero value is not usable; call New.

func New

func New() *Lifetime

New returns a Lifetime that has not ended.

func (*Lifetime) Close

func (l *Lifetime) Close()

Close cancels every operation in flight, with invoke.ErrClosed as the cause, and waits for them to return. It is idempotent.

func (*Lifetime) Enter

func (l *Lifetime) Enter(ctx context.Context) (context.Context, func(), error)

Enter begins an operation, returning the context it runs on and the function that ends it, which the caller must call. The context ends with the caller's or when the Environment closes, whichever comes first. A closed Lifetime refuses with an error wrapping invoke.ErrClosed.

Jump to

Keyboard shortcuts

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