bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package platform
|
|
|
|
// When selects the temporal slot for command-level Observer hooks. The
|
|
// framework wraps every command's RunE so both stages always fire, even
|
|
// when RunE itself returns an error (After is failure-safe).
|
|
type When int
|
|
|
|
const (
|
|
// Before fires immediately before the command's business logic.
|
|
Before When = iota
|
|
|
|
// After fires after the command's business logic (or its denyStub
|
|
// in the denied path). Always fires, even when RunE returned an
|
|
// error; Invocation.Err is populated in that case.
|
|
After
|
|
)
|
|
|
|
// LifecycleEvent selects the temporal slot for Lifecycle hooks. These are
|
|
// process-level events that fire once per binary execution, not per
|
|
// command. Only Startup and Shutdown are defined: additional bootstrap
|
|
// phases can be added later as a non-breaking addition if a concrete
|
|
// consumer surfaces.
|
|
type LifecycleEvent int
|
|
|
|
const (
|
|
// Startup fires after plugin install has committed; Plugin.On
|
|
// handlers for Startup are guaranteed to be registered before this
|
|
// event is emitted (so they can receive it).
|
|
Startup LifecycleEvent = iota
|
|
|
|
// Shutdown fires once before the process exits. Handler total
|
|
// execution is bounded by a hard 2s timeout to prevent a
|
|
// misbehaving handler from holding up exit.
|
|
Shutdown
|
|
)
|
|
|
|
// LifecycleContext is passed to LifecycleHandler. Err is the error from
|
|
// the preceding command (when Event == Shutdown after a failed RunE);
|
|
// otherwise nil.
|
|
type LifecycleContext struct {
|
|
Event LifecycleEvent
|
|
Err error
|
|
}
|