saturnin.component.service

Saturnin base module for implementation of Firebird Butler Services

It extends MicroService to provide a foundation for components that listen for and process client requests using the Firebird Butler Service Protocol (FBSP).

Constants and variables

saturnin.component.service.SVC_CHN: Final[str]

Channel name

Classes

class saturnin.component.service.ServiceConfig(name: str)[source]

Bases: ComponentConfig

Configuration for Firebird Butler Services.

This class defines settings specific to Service components, primarily the network endpoints on which the service will listen for client connections.

Parameters:

name (str) – Default configuration section name, typically the service name.

endpoints: ListOption

Service endpoint addresses

class saturnin.component.service.Service(*args, **kwargs)[source]

Bases: MicroService

Base class for Firebird Butler Services.

This class extends MicroService to implement a server component that communicates with clients using the Firebird Butler Service Protocol (FBSP) over a ZMQ ROUTER socket. It handles the setup of the FBSP service protocol and expects subclasses to register specific API handlers.

Parameters:
  • zmq_context – ZeroMQ Context.

  • descriptor – Service descriptor.

  • peer_uid – Peer ID, None means that newly generated UUID type 1 should be used.

initialize(config: ServiceConfig) None[source]

Verify configuration and assemble service structural parts.

Parameters:

config (ServiceConfig) – Service configuration.

Return type:

None

abstractmethod register_api_handlers(service: FBSPService) None[source]

Called by initialize() to allow subclasses to register their specific API handlers and FBSP service event handlers.

Implementations of this method should use the provided service protocol instance to register handlers for various FBSP message types and API calls defined by the service.

Parameters:

service (FBSPService) – The FBSPService protocol instance associated with this service’s main communication channel.

Return type:

None

start_activities() None[source]

Starts normal service activities.

This typically involves enabling the service to accept incoming client requests on its main channel. Must raise an exception if starting activities fails.

Return type:

None

stop_activities() None[source]

Stop service activities.

Calls FBSPService.close and disables receiving incoming messages on the channel.

Return type:

None

svc_channel: RouterChannel

Channel for communication with service clients.