Module: Async::Service::ManagedEnvironment

Defined in:
lib/async/service/managed_environment.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#container_optionsObject

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



29
30
31
32
33
34
35
# File 'lib/async/service/managed_environment.rb', line 29

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

#countObject

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



15
16
17
# File 'lib/async/service/managed_environment.rb', line 15

def count
  nil
end

#health_check_timeoutObject

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



22
23
24
# File 'lib/async/service/managed_environment.rb', line 22

def health_check_timeout
  30
end

#preloadObject

Any scripts to preload before starting the service.



40
41
42
# File 'lib/async/service/managed_environment.rb', line 40

def preload
  []
end

#prepare!(instance) ⇒ Object

Prepare the instance for running the service.

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



56
57
58
# File 'lib/async/service/managed_environment.rb', line 56

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

#tagsObject

General tags for metrics, traces and logging.



47
48
49
# File 'lib/async/service/managed_environment.rb', line 47

def tags
  []
end