actorlock

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package actorlock serializes lifecycle RPCs per actor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelableMutex

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

CancelableMutex supports context cancellation while waiting for a lock.

func NewCancelableMutex

func NewCancelableMutex() *CancelableMutex

NewCancelableMutex returns an unlocked CancelableMutex.

func (*CancelableMutex) Lock

func (m *CancelableMutex) Lock()

Lock acquires the mutex, blocking until it is free.

func (*CancelableMutex) LockContext

func (m *CancelableMutex) LockContext(ctx context.Context) bool

LockContext returns false on cancellation without acquiring the mutex.

func (*CancelableMutex) Unlock

func (m *CancelableMutex) Unlock()

Unlock releases the mutex.

type InFlight

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

InFlight tracks lifecycle RPCs by actor for shutdown cancellation and draining.

func NewInFlight

func NewInFlight() *InFlight

NewInFlight returns an empty set.

func (*InFlight) Add

func (f *InFlight) Add(actorUID, name string, cancel context.CancelFunc) func()

Add records an RPC for actorUID and returns the function that clears it. cancel is nil for an RPC that must finish, such as a checkpoint saving state.

func (*InFlight) CancelStartups

func (f *InFlight) CancelStartups() []string

CancelStartups cancels startup RPCs and returns their actor UIDs.

func (*InFlight) Names

func (f *InFlight) Names() map[string]string

Names returns the RPC name for each active actor.

func (*InFlight) WaitIdle

func (f *InFlight) WaitIdle(ctx context.Context) bool

WaitIdle waits for all RPCs to finish, returning false on cancellation.

type Locks

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

Locks serializes lifecycle RPCs per actor.

func New

func New() *Locks

New returns an empty set of per-actor locks.

func (*Locks) Busy added in v0.5.0

func (l *Locks) Busy(actorUID string) bool

Busy reports whether a lifecycle RPC holds or is waiting for the named actor's lock. It never blocks, so a reader that must not take the lock can still tell whether the actor is mid-operation. The answer may be stale by the time it returns: use it for advisory checks, not to decide lifecycle actions.

func (*Locks) Lock

func (l *Locks) Lock(ctx context.Context, actorUID string) bool

Lock returns false on cancellation without acquiring the actor's lock.

func (*Locks) Unlock

func (l *Locks) Unlock(actorUID string)

Unlock releases the named actor's lock.

Jump to

Keyboard shortcuts

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