mlox.service
Service base abstractions and lifecycle contract for deployable MLOX services.
Purpose:
- Provide the common dataclass model and lifecycle methods shared by all concrete services.
Key public classes/functions:
AbstractServicecore base class with setup/spin/check/teardown interfaces- helper methods for compose execution, dependency lookup, and URL/port registration
Expected runtime mode:
- Remote executor backend used from CLI/UI/TUI workflows
Related modules (plain-text links):
Return the local path for a portable packaged asset reference.
Simple service artifact template using @variable placeholders.
Return a normalized health payload from a service probe result.
Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto[T](Protocol):
def meth(self) -> T:
...
Return the directory containing the concrete service implementation.
Resolve a persisted package-relative asset for local filesystem use.
Render a service-local template with explicit @variable values.
Templates are resolved relative to the concrete service implementation
module, so service artifacts can live next to k8s.py, docker.py,
and the service mlox.*.yaml descriptor.
Render a service-local template and write it to a remote path.
Return a safe one-line YAML scalar representation.
Indent a multiline block for embedding in YAML block scalars.
Return a mapping of secret identifiers to structured secret payloads.
Start the service.
Concrete services should override this method to perform any
provisioning logic required to run the service. The default
implementation exists solely to satisfy type checkers and unit tests
that rely on instantiating AbstractService subclasses without
providing spin control behavior.
Tear down the docker compose stack for this service.
Return docker compose state for tracked services.
Attempts to use docker compose ps to retrieve structured service state
information. Falls back to inspecting individual containers when the
structured output is unavailable.
Return the recent log tail for a tracked compose service label.
Resolves the compose service name to a container name using the same
heuristics as compose_service_status and then returns the last
tail lines using the remote helper.
Return selectable log labels for this service.
Docker-backed services use their compose labels by default. Kubernetes services can override this to expose deployment, pod, or container labels without making callers know the backend.
Return recent logs for the selected service log label.
Get a compatible dependent service by UUID via the bound lookup.