Module: Async::Service::Managed::Environment

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.



37
38
39
40
41
42
43
44
# File 'lib/async/service/managed/environment.rb', line 37

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

#countObject

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



16
17
18
# File 'lib/async/service/managed/environment.rb', line 16

def count
  nil
end

#health_check_timeoutObject

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



30
31
32
# File 'lib/async/service/managed/environment.rb', line 30

def health_check_timeout
  30
end

#preloadObject

Any scripts to preload before starting the service.



49
50
51
# File 'lib/async/service/managed/environment.rb', line 49

def preload
  []
end

#prepare!(instance) ⇒ Object

Prepare the instance for running the service.

This is called before Service#run.



65
66
67
# File 'lib/async/service/managed/environment.rb', line 65

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

#startup_timeoutObject

The timeout duration for the startup. Set to nil to disable the startup timeout.



23
24
25
# File 'lib/async/service/managed/environment.rb', line 23

def startup_timeout
  nil
end

#tagsObject

General tags for metrics, traces and logging.



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

def tags
  []
end