state_machine
State machine for parsing systemd unit journal entries.
Classes:
-
State–Abstract base class for state machine states.
-
SystemdUnitStateChange–Event emitted when a systemd unit changes state.
-
SystemdUnitStateMachine–State machine for tracking a systemd unit's state via journal entries.
State
dataclass
Bases: ABC
Abstract base class for state machine states.
-
API Reference
linuxptp_monitor
-
API Reference
linuxptp_monitor
Methods:
-
parse–Parse a journal entry and yield events, returning the next state.
parse
abstractmethod
parse(entry: JournalEntry) -> Generator[Event, None, State]
Parse a journal entry and yield events, returning the next state.
SystemdUnitStateChange
dataclass
Event emitted when a systemd unit changes state.
Attributes:
-
API Reference
linuxptp_monitorstate_machineSystemdUnitStateMachineconsume
SystemdUnitStateMachine
SystemdUnitStateMachine(
inner_state_factory: Callable[[], State | None],
inner_state_on_exit: Callable[[State], None],
unit_name: str,
)
State machine for tracking a systemd unit's state via journal entries.
Parameters:
-
inner_state_factory(Callable[[], State | None]) –Factory to create the running state.
-
inner_state_on_exit(Callable[[State], None]) –Callback when the unit stops.
-
unit_name(str) –The systemd unit name to monitor.
Classes:
-
Uninitialized–State before the unit has started or after it stopped.
Methods:
-
consume–Process journal entries, yielding events and state changes.
Uninitialized
dataclass
Bases: State
State before the unit has started or after it stopped.
Attributes:
-
factory(Callable[[], State | None]) –Factory function to create the initial running state. Called when the unit starts. Can be called multiple times if the unit restarts.
Methods:
-
__eq__–Check equality with another Uninitialized state.
-
parse–Try to instantiate an initial state, and parse the incoming entry with it.
parse
parse(entry: JournalEntry) -> Generator[Event, None, State]
Try to instantiate an initial state, and parse the incoming entry with it.
consume
consume(
entries: list[JournalEntry],
) -> Generator[Event | SystemdUnitStateChange, None, None]
Process journal entries, yielding events and state changes.