pallet.crate.service documentation

Run services under supervision.

This crate provides a framework for a process under supervision. It can be extended by different supervision providers, by providing methods for the various multi-methods. A crate can provide configuration for use with a range of supervision providers.

To control a service, the service function is used.

To configure a job for a service, implement a supervisor-config-map for the facility and supervision service you wish to use. Ensure the server-spec for the supervision implementation is extended by your group-spec.

To create an implementation for a new service supervision provider, implement methods for service-supervisor-available?, service-supervisor and service-supervisor-config.

service

fn

[{:keys [supervisor service-name], :as settings} {:keys [action if-flag if-stopped instance-id], :as options}]

Control a process under supervision.

The settings map must provide :service-name and :supervisor keys. The :supervisor key specifies a keyword for the supervisor provider to dispatch to. The :service-name provides a service name to be used by the supervision provider. It is not an error to call with :action :start if the process is already running.

:action One of :enable, :disable, :start, :stop, :restart, :status. Defaults to :start.

:if-stopped Flag to only apply the action if the service is currently stopped.

:if-flag Flag to only apply the action only if the specified flag is set.

:instance-id Specifies an instance id, should there be more than one instance of the supervisor (not the facility).

service-supervisor

var

Provides an open dispatched supervisor implementation.

Implement a method dispatched on the supervisor keyword to add a supervisor implementation.

In options:

:action : the action to be performed. Should support :start, :stop and :restart.

:instance-id : specifies the supervisor instance-id, not the facility instance-id.

The :start action should not complain if the service is already running.

The :restart action should not complain if the service is not running.

The :stop action should not complain if the service is not running.

service-supervisor-available?

var

Predicate to test if a given service implementation is available.

service-supervisor-config

var

Configure a service implementation based on configuration map. The config map is specific to the supervisor. The initial enabled status of a config is supervisor specific.

supervisor-config

fn

[facility {:keys [supervisor], :as settings} options]

Configure service supervision for facility based on configuration map.

Supervisor specific options are specified under the supervisor key in the settings map.

This is intended to be called at the crate level.

supervisor-config-map

var

Return a service configuration map for the given supervisor and facility.

A method should be implemented in each crate for each supervisor to be supported.