// Package deploy provides deployment execution logic. package deploy import ( "sync" ) // Lock provides a simple in-memory lock for single-deployment concurrency control. type Lock struct { mu sync.Mutex held bool holder string } // NewLock creates a new deployment lock. func NewLock() *Lock { return &Lock{} } // TryAcquire attempts to acquire the lock. Returns true if successful. // The holder parameter identifies who is holding the lock. func (l *Lock) TryAcquire(holder string) bool { l.mu.Lock() defer l.mu.Unlock() if l.held { return false } l.held = true l.holder = holder return true } // Release releases the lock. func (l *Lock) Release() { l.mu.Lock() defer l.mu.Unlock() l.held = false l.holder = "" } // IsHeld returns true if the lock is currently held. func (l *Lock) IsHeld() bool { l.mu.Lock() defer l.mu.Unlock() return l.held } // Holder returns the current holder of the lock, or empty string if not held. func (l *Lock) Holder() string { l.mu.Lock() defer l.mu.Unlock() return l.holder }