lifecyclecleanup

package
v0.1.0-alpha.1 Latest Latest
Warning

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

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

Documentation

Overview

Package lifecyclecleanup releases what a component's failed Start acquired, under a bounded context that the failure cannot cancel.

A component whose Start can fail after acquiring something (a subscription, a goroutine, a connection) cleans up its own failed start with RollbackFailedStart. The component manager and the service manager still call Stop after a failed Start, as a second line. A component that calls the helper does five things:

  1. Before its first acquisition, it records that cleanup is pending.
  2. On a failure after that, it calls RollbackFailedStart synchronously, before Start returns, with Start's own context and its cleanup function.
  3. It joins the helper's result into Start's error, so the caller sees both the start failure and any cleanup failure.
  4. It clears the cleanup-pending record only when the helper returns nil. Otherwise it keeps the record and the handles it could not release.
  5. When Stop is called after a failed Start, it releases whatever is still held and returns an error naming what it could not release.

SemEngine's own components get these from internal/lifecycleguard. SemEngine can test the helper and its managers; only a component's own tests can show that the component follows the five.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RollbackFailedStart

func RollbackFailedStart(parent context.Context, rollback func(context.Context) error) error

RollbackFailedStart runs rollback synchronously under a context that keeps parent's values but not its cancellation or deadline, with a deadline five seconds after the call. It returns rollback's error joined with that context's error, so nil means the rollback returned nil within the budget. A nil parent or a nil rollback is refused with an error, and nothing runs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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