Saturnin component registration and discovery.

Services are registered as entry points for their ServiceDescriptor - i.e. the instance of ServiceDescriptor for installed service is returned by EntryPoint.load().

The default group for service registration is saturnin.service, but it’s possible to install additional service discovery iterators.

Custom service iterator must be a generator that accepts optional uid in string format, and yileds importlib.metadata.EntryPoint instances. If uid is specified, it must return only EntryPoint only for service with given uid, otherwise it should return all services.


Custom iterator can return objects that are not EntryPoint instances, but they MUST implement load() method that will return ServiceDescriptor instance.

Custom iterators must be registered as entry points in saturnin.service.iterator group.


saturnin.component.registry.service_registry: ServiceRegistry

Saturnin service registry


class saturnin.component.registry.ServiceInfo(*, uid: UUID, name: str, version: str, vendor: UUID, classification: str, description: str, facilities: List[str], api: List[UUID], factory: str, descriptor: str, distribution: str)[source]

Bases: Distinct

Information about service stored in ServiceRegistry.

  • uid (UUID) – Service UID

  • name (str) – Service name

  • version (str) – Service version

  • vendor (UUID) – Service vendor UID

  • classification (str) – Service classification

  • description (str) – Service description

  • facilities (List[str]) – List of service facilities

  • api (List[UUID]) – List of interfaces provided by service

  • factory (str) – Service factory specification (entry point)

  • descriptor (str) – Service descriptor specification (entry point)

  • distribution (str) – Installed distribution package that contains this service

as_toml_dict() Dict[source]

Returns dictionary with instance data suitable for storage in TOML format (values that are not of basic type are converted to string).

Return type:


get_key() Hashable[source]

Returns service UID

Return type:


api: List[UUID]

List of interfaces provided by service

classification: str

Service classification

description: str

Service description

descriptor: str

Service descriptor specification (entry point)

property descriptor_obj: ServiceDescriptor

Service descriptor object. If it’s not assigned directly, then it’s loaded using descriptor on first access.

distribution: str

Installed distribution package that contains this service

facilities: List[str]

List of service facilities

factory: str

Service factory specification (entry point)

property factory_obj: Any

Service factory object. If it’s not assigned directly, then it’s loaded using factory on first access.

name: str

Service name

uid: UUID

Service UID

vendor: UUID

Service vendor UID

version: str

Service version

class saturnin.component.registry.ServiceRegistry(data: Mapping | Sequence | Registry = None)[source]

Bases: Registry

Saturnin service registry.

Holds ServiceInfo instances.

It is used in two modes:

  1. In full saturnin deployment, the information about services is loaded from TOML file. Service descriptors and factories are loaded on demand.

  2. In standalone service/bundle mode, service information including service desciptors and factories is stored directly by executor script, so there is no dynamic discovery and the whole could be compiled with Nutika.


data (Union[Mapping, Sequence, Registry]) –

add(descriptor: ServiceDescriptor, factory: Any, distribution: str) None[source]

Direct service registration. Used by systems that does not allow dynamic discovery, for example programs compiled by Nuitka.

  • descriptor (ServiceDescriptor) – Service descriptor

  • factory (Any) – Service factory

  • distribution (str) – Distribution package name with service

Return type:


as_toml() str[source]

Returns registry content as TOML document.

Return type:


get_by_name(name: str, default: Any = None) Distinct[source]

Get service by its name.

  • name (str) – Service name.

  • default (Any) – Default value returned when service is not found.

Return type:


load() None[source]

Read information about installed services from previously saved TOML file.

Return type:


load_from_installed(*, ignore_errors: bool = False) None[source]

Populate registry from descriptors of installed services.


ignore_errors (bool) – When True, errors are ignored, otherwise Error is raised.

Return type:


load_from_toml(toml: str, *, ignore_errors: bool = False) None[source]

Populate registry from TOML document.

  • toml (str) – TOML document (as created by as_toml method).

  • ignore_errors (bool) – When True, errors are ignored, otherwise Error is raised.

Return type:


save() None[source]

Save information about installed services to TOML file.

Return type: