Class SilaServer¶
- class sila2.server.SilaServer(server_name: str, server_type: str, server_description: str, server_version: str, server_vendor_url: str, server_uuid: UUID | str | None = None, max_grpc_workers: int = 100, max_child_task_workers: int = 100, default_binary_transfer_lifetime: timedelta = datetime.timedelta(seconds=60))¶
SiLA Server
- Parameters:
server_name – SiLA Server Name, max. 255 characters
server_type – SiLA Server Type, must start with a capital letter and can only contain letters (a-z, A-Z) and digits (0-9)
server_description – SiLA Server Description
server_version –
SiLA Server Version, e.g.
"1.2"
,"1.2.3"
, or"1.2.3_beta"
.Pattern:
Major.Minor.Patch_Details
, where Major, Minor und Patch are numeric, Details is text (a-z, A-Z, 0-9, _). Patch and Details are optional.server_vendor_url – SiLA Server Vendor URL: The product or vendor homepage, must start with
"http://"
or"https://"
server_uuid – SiLA Server UUID. If given as a string, it must be formatted like
"082bc5dc-18ae-4e17-b028-6115bbc6d21e"
max_grpc_workers – Max. number of worker threads used by gRPC
max_child_task_workers – Max. number of worker threads used by the implementation (e.g. observable command instances, observable property subscriptions, …)
- metadata_interceptors: typing.List[MetadataInterceptor]¶
Registered metadata interceptors
- children_by_fully_qualified_identifier: typing.Dict[FullyQualifiedIdentifier, Feature | Command | Property | Parameter | Response | IntermediateResponse | DefinedExecutionErrorNode | DataTypeDefinition | Metadata]¶
All child elements, accessible by their fully qualified identifier
- generated_ca: bytes | None¶
PEM-encoded certificate authority of self-signed certificate, if generated on server startup
- set_feature_implementation(feature: Feature, implementation: FeatureImplementationBase) None ¶
Set a feature implementation
- Parameters:
feature – Feature to implement
implementation – Feature implementation
- Raises:
RuntimeError – If the server was already started, or another implementation of the feature already was set
- add_metadata_interceptor(interceptor: MetadataInterceptor)¶
Add an interceptor for SiLA Client Metadata handling
- Parameters:
interceptor – Interceptor to add
- Raises:
RuntimeError – If the server is already running
- start_insecure(address: str, port: int, enable_discovery: bool = True) None ¶
Start the server using unencrypted communication
- Parameters:
address – IP address or hostname where the server should run
port – Port where the server should run
enable_discovery – Whether to broadcast the server address for SiLA Server Discovery
Warning
Using unencrypted communication violates the SiLA specification and should only be used for testing purposes
Notes
From the SiLA Specification:
It is RECOMMENDED that all SiLA Servers have SiLA Server Discovery enabled by default, but all SiLA Devices MUST have SiLA Server Discovery enabled by default.
- start(address: str, port: int, private_key: bytes | None = None, cert_chain: bytes | None = None, ca_for_discovery: bytes | None = None, enable_discovery: bool = True)¶
Start the server using unencrypted communication
When no encryption information is provided, a self-signed certificate is generated. Its PEM-encoded certificate authority is then stored in
sila2.server.SilaServer.generated_ca
.- Parameters:
address – IP address or hostname where the server should run
port – Port where the server should run
private_key – PEM-encoded private key for encrypted communication
cert_chain – PEM-encoded certificate chain for encrypted communication
ca_for_discovery – PEM-encoded certificate of the certificate authority that should be used in the SiLA Server Discovery (only useful if you manually provide an untrusted certificate)
enable_discovery – Whether to broadcast the server address for SiLA Server Discovery
Notes
From the SiLA Specification:
It is RECOMMENDED that all SiLA Servers have SiLA Server Discovery enabled by default, but all SiLA Devices MUST have SiLA Server Discovery enabled by default.