process_metadata
drunc.processes.process_metadata
Process metadata management for remote processes.
Classes
ProcessMetadata(pid=None, hostname=None, user=None, started_at=None, tree_id=None, role=None, name=None)
dataclass
Metadata about a remote process.
Stores process information that needs to persist across connections, including the remote process ID for signal delivery.
Methods:
compute_role_from_tree_id(tree_id, is_controller=False)
staticmethod
Determines the role of a process based on its tree_id and executable type.
- empty tree_id -> "unknown"
- is_controller + tree_id == "0" -> "root-controller"
- is_controller + tree_id starts with "0." -> "segment-controller"
- is_controller + otherwise -> "infrastructure-applications"
- not controller + tree_id starts with "0." -> "application"
- not controller + otherwise -> "infrastructure-applications"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tree_id
|
str
|
Dot-separated hierarchical identifier (e.g. "0", "0.1", "0.1.2.3"). |
required |
is_controller
|
bool
|
True if the process executable is a drunc-controller. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Role string: "root-controller", "segment-controller", "application", "infrastructure-applications", or "unknown" |
Source code in drunc/processes/process_metadata.py
from_dict(data)
classmethod
Create ProcessMetadata from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Dictionary containing metadata fields |
required |
Returns:
| Type | Description |
|---|---|
ProcessMetadata
|
ProcessMetadata instance |
Source code in drunc/processes/process_metadata.py
from_json(json_str)
classmethod
Deserialise metadata from JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_str
|
str
|
JSON string containing metadata |
required |
Returns:
| Type | Description |
|---|---|
ProcessMetadata
|
ProcessMetadata instance |
Source code in drunc/processes/process_metadata.py
to_dict()
Convert metadata to dictionary for JSON serialisation.
Source code in drunc/processes/process_metadata.py
to_json()
Serialise metadata to JSON string.
Returns:
| Type | Description |
|---|---|
str
|
JSON string representation |