LauncherProtocol#
- class ansys.tools.common.abstractions.launcher.LauncherProtocol(*, config: LAUNCHER_CONFIG_T)#
Bases:
Protocol[LAUNCHER_CONFIG_T]Provides the interface for managing a local product instance.
A plugin to the local product launcher must implement the interface defined in this class.
To check for compatibility, you should derive from this class. For example
MyLauncher(LauncherProtocol[MyConfigModel]). Check the resulting code with Mypy.The
__init__method should accept exactly one keyword-only parameter:config. Note that this is not enforced by Mypy.Parameters#
- config :
Configuration options used to start the product. This parameter must be an instance of
CONFIG_MODEL.
Overview#
Dictionary of URLs that the server is listening on. |
Defines the configuration options for the launcher. |
|
Defines the server types that are started. |
Import detail#
from ansys.tools.common.abstractions.launcher import LauncherProtocol
Property detail#
- property LauncherProtocol.urls: dict[str, str]#
Dictionary of URLs that the server is listening on.
The keys of the returned dictionary must correspond to the keys defined in the
LauncherProtocol.SERVER_SPECattribute.
Attribute detail#
- LauncherProtocol.CONFIG_MODEL: type[LAUNCHER_CONFIG_T]#
Defines the configuration options for the launcher.
The configuration options that this launcher accepts, specified as a
dataclass. Note that thedefaultandmetadata[METADATA_KEY_DOC]of the fields are used in the configuration CLI, if available.
- LauncherProtocol.SERVER_SPEC: dict[str, ServerType]#
Defines the server types that are started.
Examples#
This code defines a server that is accessible via a URL at the
"MAIN"key and a server accessible via gRPC at the"FILE_TRANSFER"key.SERVER_SPEC = {"MAIN": ServerType.GENERIC, "FILE_TRANSFER": ServerType.GRPC}
The
ProductInstance.urlsattribute then has keys{"MAIN", "FILE_TRANSFER"}, whereas theProductInstance.channelsattribute has only the key"FILE_TRANSFER".
Method detail#
- LauncherProtocol.start() None#
Start the product instance.
- LauncherProtocol.stop(*, timeout: float | None = None) None#
Stop the product instance.
Parameters#
- timeout :
Time after which the instance can be forcefully stopped. The timeout should be interpreted as a hint to the implementation. It is not required to trigger a force-shutdown, but the stop must return within a finite time.
- LauncherProtocol.check(*, timeout: float | None = None) bool#
Check if the product instance is responding to requests.
Parameters#
- timeout :
Timeout in seconds for the check. The timeout should be interpreted as a hint to the implementation. It is not required to return within the given time, but the check must return within a finite time, meaning it must not hang indefinitely.
Returns#
- bool
Whether the product instance is responding.