Service#
lit.sdk.services.service
#
This module defines the Service abstract base class, representing a generic service within
a system. It also defines the data structures for handling service actions and status.
This module is intended to be subclassed by other classes that implement specific behaviors for different services. The data structures provide a standard format for handling service-related information.
Service
#
Bases: ABC
Abstract base class for managing services.
name = name
instance-attribute
#
The name of the service.
team = team
instance-attribute
#
The name of the team that owns the service.
__init__(team, name)
#
Initializes a new instance of Service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
The name of the team that owns the service. |
required |
name
|
str
|
The name of the service. |
required |
restart()
abstractmethod
#
Restarts the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
start()
abstractmethod
#
Starts the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
status()
abstractmethod
#
Retrieves the status of the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceStatus |
ServiceStatus
|
A dictionary containing the current status of the service. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
stop()
abstractmethod
#
Stops the service.
Returns:
| Name | Type | Description |
|---|---|---|
ServiceActionStatus |
ServiceActionStatus
|
A dictionary containing the status of the operation. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the method is not implemented by a subclass. |
Examples:
ServiceActionStatus
#
ServiceStatus
#
Bases: TypedDict
Represents the status of a service.
Examples:
>>> service_status: ServiceStatus = {
... "name": "my_service",
... "active": "active",
... "status": "running",
... "started": "Wed 2024-07-24 13:32:23 CDT",
... "pid": 3687984,
... "tasks": 5,
... "memory": "3.3G"
... }
active
instance-attribute
#
The active status of the service (e.g., 'active', 'inactive').
memory
instance-attribute
#
The memory usage of the service.
name
instance-attribute
#
The name of the service.
pid
instance-attribute
#
The process ID associated with the service.
started
instance-attribute
#
The timestamp when the service was started.
status
instance-attribute
#
The detailed status of the service (e.g., 'running', 'stopped').
tasks
instance-attribute
#
The number of tasks or threads the service is running.