pub fn acquire_or_emit(
socket_dir: &Path,
command: Command,
json: bool,
silent: bool,
dry_run: bool,
timeout: Duration,
break_lock: bool,
) -> Result<LockAcquired, i32>Expand description
Try to acquire <socket_dir>/apply.lock and return the guard, or
emit a failure envelope and a non-zero exit code.
command selects the envelope’s command field so downstream
consumers see apply / rollback / repair / remove rather
than a generic “lock failed”. dry_run is plumbed through to the
envelope’s dry_run field for the (rare) case where lock
contention happens during a dry-run apply.
timeout = Duration::ZERO keeps the historical non-blocking
try-once shape. Positive values wait with a 100 ms backoff —
see socket_patch_core::patch::apply_lock::acquire.
break_lock = true deletes <socket_dir>/apply.lock before the
acquire attempt. The motivating case is a crashed prior run that
left the file but no OS lock. When the file exists and is
successfully removed the return value’s broke_lock is true and
the caller should attach a lock_broken warning event to their
envelope.