nodeidentity

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nodeidentity owns the process-wide identity lock for a running node. It deliberately keys locks by node kind and stable identity: one physical node per host, while a VM on that host may hold a separate VM lock.

Index

Constants

View Source
const (
	KindPhysical = "physical"
	KindVM       = "vm"
)

Variables

View Source
var ErrAlreadyRunning = errors.New("node identity already running")

ErrAlreadyRunning identifies a live process holding the same node identity. Callers should use errors.Is instead of parsing platform-specific errors.

Functions

func Held

func Held(kind, identity string) (bool, error)

Held reports whether another process currently owns the identity lock.

Types

type Lock

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

Lock is held for the lifetime of a daemon process.

func Acquire

func Acquire(kind, identity string) (*Lock, error)

Acquire obtains the exclusive local lock for kind/identity. The OS-level advisory lock is released automatically if the process exits unexpectedly.

Only contention is reported as ErrAlreadyRunning. A lock that cannot be taken for any other reason — an unreadable config directory, a volume that refuses locks — comes back as itself, because callers draw opposite conclusions from the two: a daemon treats ErrAlreadyRunning as "another node is up" and stands down, and Held reports it as "the row has an owner". Reporting an I/O error as contention is how a broken environment turned into a false demotion.

func (*Lock) Release

func (l *Lock) Release() error

Release releases the OS lock. The lock file itself is intentionally kept: that makes startup races deterministic and avoids stale PID-file recovery.

Jump to

Keyboard shortcuts

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