Documentation
¶
Index ¶
- Constants
- func ActiveSessionLimitMessage(activeCount int, maxSessions *big.Int, entries []*jsonutil.Object) string
- func CoerceMaxConcurrentSessions(value any, key string) *big.Int
- func FileLock(path string, timeout time.Duration) (func(), error)
- func FormatAge(seconds float64) string
- func FormatRefusalStderr(message *Refusal) string
- func LivenessGuard(ctx context.Context, sessionID, registryHome string, ...) error
- func MarkReleaseQueued(lease any)
- func OwnStartTime() (float64, bool)
- func PidLiveness(pid, processStart any) (alive, known bool)
- func PruneDead(entries []*jsonutil.Object, strict bool) ([]*jsonutil.Object, error)
- func ReadEntries(path string, strict bool) ([]*jsonutil.Object, error)
- func RegistrySnapshot(ctx context.Context, registryHome string, strict bool) ([]*jsonutil.Object, error)
- func ReleaseActiveSession(lease *Lease) error
- func ReleaseOrphanedLeases(liveLeaseIDs map[string]bool) (int, error)
- func ResolveMaxConcurrentSessions(config any) *big.Int
- func SessionAlreadyOwnedMessage(sessionID string, entry *jsonutil.Object) string
- func SessionOwnerDetails(sessionID string, entry *jsonutil.Object) string
- func SummarizeHolders(entries []*jsonutil.Object) string
- func TransferActiveSession(lease *Lease, sessionID string, metadata map[string]any) (bool, error)
- func TryAcquire(ctx context.Context, sessionID, surface string, cfg any, ...) (*Lease, *Refusal, error)
- type Lease
- type LockUnavailableError
- type Refusal
- type RegistryError
Constants ¶
const ( SessionNotOwned = "SESSION_NOT_OWNED" MaxConcurrentSessions = "MAX_CONCURRENT_SESSIONS" )
Machine readable refusal reasons, capacity and ownership calling for different operator action
const NoLockTimeout time.Duration = -1
Waits on a registry lock with no deadline
const PerSessionExclusiveSubmit = true
Exclusive per session submit the gateway advertises, held by the atomic acquisition check
Variables ¶
This section is empty.
Functions ¶
func ActiveSessionLimitMessage ¶
func ActiveSessionLimitMessage(activeCount int, maxSessions *big.Int, entries []*jsonutil.Object) string
Capacity refusal text naming the surfaces that hold the slots
func CoerceMaxConcurrentSessions ¶
Positive integer session cap of a config value, nil when disabled or invalid with a warning logged
func FormatRefusalStderr ¶
Refusal text prefixed with its reason line so the contract survives a subprocess boundary
func LivenessGuard ¶
func LivenessGuard(ctx context.Context, sessionID, registryHome string, ownLiveLeaseIDs map[string]bool, body func(active bool) error) error
Runs body holding the registry lock with whether the session is leased, so no claim lands between check and write
func MarkReleaseQueued ¶
func MarkReleaseQueued(lease any)
Retires a lease from this process view of the registry now, its file write coming later
func OwnStartTime ¶
Creation time of this process, false when the platform cannot read it
func PidLiveness ¶
Whether the pid is still the process that started then, known false when liveness cannot be decided
func ReadEntries ¶
Registry rows of path, strict mode raising on a corrupt or malformed registry
func RegistrySnapshot ¶
func RegistrySnapshot(ctx context.Context, registryHome string, strict bool) ([]*jsonutil.Object, error)
Live leases of the registry, dead ones written out under a second lock, strict requiring provable owners
func ReleaseActiveSession ¶
Drops the lease from the registry it was acquired against, an unreadable untracked registry preserved
func ReleaseOrphanedLeases ¶
Drops the registry entries of this process no live session owns across the root and every profile home
func ResolveMaxConcurrentSessions ¶
Top level max_concurrent_sessions of a config with the gateway section as the fallback
func SessionAlreadyOwnedMessage ¶
Refusal text for a session another live process holds, the plain sentence first and details second
func SessionOwnerDetails ¶
Details line every owner refusal message carries, the surface and age of the holding lease
func SummarizeHolders ¶
Compact holders phrase like tui x4, cli with the age of the oldest lease
func TransferActiveSession ¶
Moves a lease to a new session id without dropping its slot, false when it cannot be moved
Types ¶
type Lease ¶
type Lease struct {
LeaseID string
Surface string
Enabled bool
StatePath string
LockPath string
TrackLiveness bool
// contains filtered or unexported fields
}
Active session slot recorded in a registry until it is released
func (*Lease) Release ¶
Drops the lease from its registry once, a disabled lease never touching the file
func (*Lease) TracksLiveness ¶
Whether the lease records its owner process for cross process liveness checks
type LockUnavailableError ¶
type LockUnavailableError struct {
}
Registry lock that could not be taken, the cause wrapped
func (*LockUnavailableError) Error ¶
func (e *LockUnavailableError) Error() string
Message naming the lock file
func (*LockUnavailableError) Unwrap ¶
func (e *LockUnavailableError) Unwrap() error
Cause of the lock failure
type Refusal ¶
Refusal of an acquisition, the message for people and the reason as the contract; a plain value that a deep copy reproduces field for field
func NewRefusal ¶
Refusal carrying a message for people and a machine readable reason
func (*Refusal) MarshalText ¶
Message of the refusal, the JSON string a payload carrying it encodes it as
type RegistryError ¶
type RegistryError struct {
// contains filtered or unexported fields
}
RegistryError reports an unreadable registry or an owner whose liveness cannot be proven
func (*RegistryError) Error ¶
func (e *RegistryError) Error() string
Message of the registry failure