leglifecycle

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package leglifecycle owns A-leg scoped cancellation and B-leg teardown policy.

Package leglifecycle B-leg attempt lifecycle coordinator.

Index

Constants

View Source
const (
	CancelExplicit    = lipapi.CancelExplicit
	CancelClientGone  = lipapi.CancelClientGone
	CancelContextDone = lipapi.CancelContextDone
	CancelRaceLoser   = lipapi.CancelRaceLoser
)
View Source
const (
	CancelModeNone      = lipapi.CancelModeNone
	CancelModeProvider  = lipapi.CancelModeProvider
	CancelModeTransport = lipapi.CancelModeTransport
	CancelModeCloseOnly = lipapi.CancelModeCloseOnly
)
View Source
const DefaultCancelTimeout = 2 * time.Second

DefaultCancelTimeout bounds B-leg Cancel when CoordinatorConfig.CancelTimeout is unset.

Variables

View Source
var ErrALegCanceled = errors.New("leglifecycle: a-leg canceled")

Functions

This section is empty.

Types

type ALeg

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

func (*ALeg) BeginBLegLaunch

func (a *ALeg) BeginBLegLaunch(parent context.Context, bLegID string) (context.Context, *LaunchPermit, error)

func (*ALeg) Cancel

func (a *ALeg) Cancel(ctx context.Context, cause CancelCause) error

func (*ALeg) End

func (a *ALeg) End()

func (*ALeg) Err

func (a *ALeg) Err() error

func (*ALeg) RegisterBLeg

func (a *ALeg) RegisterBLeg(ctx context.Context, h BLegHandle) error

func (*ALeg) ReleaseBLeg

func (a *ALeg) ReleaseBLeg(id string)

type BLegAttempt

type BLegAttempt = lipapi.ManagedEventStream

type BLegHandle

type BLegHandle struct {
	ID      string
	Attempt BLegAttempt
}

type CancelCause

type CancelCause = lipapi.CancelCause

type CancelKind

type CancelKind = lipapi.CancelKind

type CancelMode

type CancelMode = lipapi.CancelMode

type CancelResult

type CancelResult = lipapi.CancelResult

func BoundedCancelAndClose

func BoundedCancelAndClose(
	parent context.Context,
	timeout time.Duration,
	cancelFn func(context.Context) CancelResult,
	closeFn func() error,
	force <-chan struct{},
) (CancelResult, error)

BoundedCancelAndClose requires Close to promptly return and unblock Cancel.

type CloseOnlyAttempt

type CloseOnlyAttempt struct {
	Closer interface{ Close() error }
}

func (CloseOnlyAttempt) Cancel

func (CloseOnlyAttempt) Close

func (a CloseOnlyAttempt) Close() error

type Coordinator

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

func NewCoordinator

func NewCoordinator(cfg CoordinatorConfig) *Coordinator

func (*Coordinator) CancelALeg

func (c *Coordinator) CancelALeg(ctx context.Context, id string, cause CancelCause) error

func (*Coordinator) EndALeg

func (c *Coordinator) EndALeg(id string)

func (*Coordinator) StartALeg

func (c *Coordinator) StartALeg(id string) *ALeg

type CoordinatorConfig

type CoordinatorConfig struct {
	CancelTimeout time.Duration
}

type LaunchCommitResult

type LaunchCommitResult struct {
	Canceled bool
	Cause    CancelCause
}

type LaunchPermit

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

func (*LaunchPermit) Abort

func (p *LaunchPermit) Abort()

func (*LaunchPermit) Commit

func (p *LaunchPermit) Commit(handle BLegAttempt) (LaunchCommitResult, error)

Jump to

Keyboard shortcuts

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