Async::ServiceSourceAsyncServiceManagedEnvironment

module ManagedEnvironment

Default configuration for managed services.

This is provided not because it is required, but to offer a sensible default for production services, and to expose a consistent interface for service configuration.

Definitions

def count

Number of instances to start. By default, when nil, uses Etc.nprocessors.

Signature

returns Integer | nil

The number of instances to start, or nil to use the default.

Implementation

def count
	nil
end

def health_check_timeout

The timeout duration for the health check. Set to nil to disable the health check.

Signature

returns Numeric | nil

The health check timeout in seconds.

Implementation

def health_check_timeout
	30
end

def container_options

Options to use when creating the container, including restart, count, and health_check_timeout.

Signature

returns Hash

The options for the container.

Implementation

def container_options
	{
		restart: true,
		count: self.count,
		health_check_timeout: self.health_check_timeout,
	}.compact
end

def preload

Any scripts to preload before starting the service.

Signature

returns Array(String)

The list of scripts to preload.

Implementation

def preload
	[]
end

def tags

General tags for metrics, traces and logging.

Signature

returns Array(String)

The tags for the service.

Implementation

def tags
	[]
end

def prepare!(instance)

Prepare the instance for running the service.

This is called before Async::Service::ManagedService#run.

Signature

parameter instance Object

The container instance.

Implementation

def prepare!(instance)
	# No preparation required by default.
end