Skip to content

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.

__doc__ = '\nThis module defines the `Service` abstract base class, representing a generic service within\na system. It also defines the data structures for handling service actions and status.\n\nThis module is intended to be subclassed by other classes that implement specific\nbehaviors for different services. The data structures provide a standard format for\nhandling service-related information.\n' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__file__ = '/opt/lit-platform/lit-lib/src/lit/sdk/services/service.cpython-312-x86_64-linux-gnu.so' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__name__ = 'lit.sdk.services.service' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__package__ = 'lit.sdk.services' module #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__test__ = {'Service.start (line 80)': '\n Starts the service.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n NotImplementedError: If the method is not implemented by a subclass.\n\n Examples:\n >>> service = SomeServiceSubclass("contoso", "service_name")\n >>> service.start()\n {\'status\': \'SUCCESS\', \'message\': \'Service started successfully.\'}\n ', 'Service.stop (line 98)': '\n Stops the service.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n NotImplementedError: If the method is not implemented by a subclass.\n\n Examples:\n >>> service = SomeServiceSubclass("contoso", "service_name")\n >>> service.stop()\n {\'status\': \'SUCCESS\', \'message\': \'Service stopped successfully.\'}\n ', 'Service.restart (line 116)': '\n Restarts the service.\n\n Returns:\n ServiceActionStatus: A dictionary containing the status of the operation.\n\n Raises:\n NotImplementedError: If the method is not implemented by a subclass.\n\n Examples:\n >>> service = SomeServiceSubclass("contoso", "service_name")\n >>> service.restart()\n {\'status\': \'SUCCESS\', \'message\': \'Service restarted successfully.\'}\n ', 'Service.status (line 134)': '\n Retrieves the status of the service.\n\n Returns:\n ServiceStatus: A dictionary containing the current status of the service.\n\n Raises:\n NotImplementedError: If the method is not implemented by a subclass.\n\n Examples:\n >>> service = SomeServiceSubclass("contoso", "service_name")\n >>> service.status()\n {\'name\': \'service_name\', \'active\': \'active\', \'status\': \'running\', \'started\': \'Wed 2024-07-24 13:32:23 CDT\', \'pid\': 3687984, \'tasks\': 5, \'memory\': \'3.3G\'}\n '} module #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

Service #

Bases: abc.ABC

Abstract base class for managing services.

__abstractmethods__ = frozenset({'stop', 'restart', 'status', 'start'}) class #

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

__annotations__ = {'team': 'str', 'name': 'str'} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__doc__ = 'Abstract base class for managing services.' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__module__ = 'lit.sdk.services.service' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__weakref__ property #

list of weak references to the object

__init__(team, name) method descriptor #

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() method descriptor #

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:

>>> service = SomeServiceSubclass("contoso", "service_name")
>>> service.restart()
{'status': 'SUCCESS', 'message': 'Service restarted successfully.'}

start() method descriptor #

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:

>>> service = SomeServiceSubclass("contoso", "service_name")
>>> service.start()
{'status': 'SUCCESS', 'message': 'Service started successfully.'}

status() method descriptor #

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:

>>> service = SomeServiceSubclass("contoso", "service_name")
>>> service.status()
{'name': 'service_name', 'active': 'active', 'status': 'running', 'started': 'Wed 2024-07-24 13:32:23 CDT', 'pid': 3687984, 'tasks': 5, 'memory': '3.3G'}

stop() method descriptor #

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:

>>> service = SomeServiceSubclass("contoso", "service_name")
>>> service.stop()
{'status': 'SUCCESS', 'message': 'Service stopped successfully.'}

ServiceActionStatus #

Bases: builtins.dict

Represents the status of a service action.

Examples:

>>> action_status: ServiceActionStatus = {
...     "status": "SUCCESS",
...     "message": "Service started successfully."
... }

__annotations__ = {'status': ForwardRef("Literal['SUCCESS', 'ERROR']", module='lit.sdk.services.service'), 'message': ForwardRef('str', module='lit.sdk.services.service')} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__doc__ = 'Represents the status of a service action.\n\n Examples:\n >>> action_status: ServiceActionStatus = {\n ... "status": "SUCCESS",\n ... "message": "Service started successfully."\n ... }\n ' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__module__ = 'lit.sdk.services.service' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__optional_keys__ = frozenset() class #

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

__orig_bases__ = (<function TypedDict at 0x7fef89f62e80>,) class #

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.

If the argument is a tuple, the return value is the same object.

__required_keys__ = frozenset({'status', 'message'}) class #

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

__total__ = True class #

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

__weakref__ property #

list of weak references to the object

ServiceStatus #

Bases: builtins.dict

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"
... }

__annotations__ = {'name': ForwardRef('str', module='lit.sdk.services.service'), 'active': ForwardRef('str', module='lit.sdk.services.service'), 'status': ForwardRef('str', module='lit.sdk.services.service'), 'started': ForwardRef('str', module='lit.sdk.services.service'), 'pid': ForwardRef('int', module='lit.sdk.services.service'), 'tasks': ForwardRef('int', module='lit.sdk.services.service'), 'memory': ForwardRef('str', module='lit.sdk.services.service')} class #

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

__doc__ = 'Represents the status of a service.\n\n Examples:\n >>> service_status: ServiceStatus = {\n ... "name": "my_service",\n ... "active": "active",\n ... "status": "running",\n ... "started": "Wed 2024-07-24 13:32:23 CDT",\n ... "pid": 3687984,\n ... "tasks": 5,\n ... "memory": "3.3G"\n ... }\n ' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__module__ = 'lit.sdk.services.service' class #

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

__optional_keys__ = frozenset() class #

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

__orig_bases__ = (<function TypedDict at 0x7fef89f62e80>,) class #

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable's items.

If the argument is a tuple, the return value is the same object.

__required_keys__ = frozenset({'active', 'name', 'pid', 'started', 'status', 'tasks', 'memory'}) class #

frozenset() -> empty frozenset object frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

__total__ = True class #

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

__weakref__ property #

list of weak references to the object