lib/orchestration/service_check.rb in orchestration-0.2.3 vs lib/orchestration/service_check.rb in orchestration-0.2.4
- old
+ new
@@ -5,11 +5,11 @@
ATTEMPT_LIMIT = 10
RETRY_INTERVAL = 3 # seconds
def initialize(service, terminal, options = {})
@service = service
- @service_name = service_name(service)
+ @service_name = service.service_name
@terminal = terminal
@attempt_limit = options.fetch(:attempt_limit, ATTEMPT_LIMIT)
@retry_interval = options.fetch(:retry_interval, RETRY_INTERVAL)
@attempts = 0
@failure_callback = options.fetch(:failure_callback, nil)
@@ -40,29 +40,49 @@
def echo_start
@terminal.write(@service_name.to_sym, '', :status)
end
def echo_waiting
- @terminal.write(
- :waiting,
- I18n.t(
- "orchestration.#{@service_name}.waiting",
- config: @service.configuration.friendly_config
- )
+ @terminal.write(:waiting, service_waiting)
+ end
+
+ def service_waiting
+ I18n.t(
+ "orchestration.#{@service_name}.waiting",
+ config: friendly_config,
+ default: default_waiting
)
end
+ def default_waiting
+ I18n.t(
+ 'orchestration.custom_service.waiting',
+ config: friendly_config,
+ service: @service_name
+ )
+ end
+
def echo_ready
- @terminal.write(
- :ready,
- I18n.t(
- "orchestration.#{@service_name}.ready",
- config: @service.configuration.friendly_config
- )
+ @terminal.write(:ready, service_ready)
+ end
+
+ def service_ready
+ I18n.t(
+ "orchestration.#{@service_name}.ready",
+ config: friendly_config,
+ default: default_ready
)
end
+ def default_ready
+ I18n.t(
+ 'orchestration.custom_service.ready',
+ config: friendly_config,
+ service: @service_name
+ )
+ end
+
def echo_failure
@terminal.write(
:failure,
I18n.t('orchestration.attempt_limit', limit: @attempt_limit)
)
@@ -70,12 +90,10 @@
def echo_error(error)
@terminal.write(:error, "[#{error.class.name}] #{error.message}")
end
- def service_name(service)
- # e.g.:
- # Orchestration::Services::RabbitMQ::Healthcheck => 'rabbitmq'
- service.class.name.split('::')[-2].downcase
+ def friendly_config
+ @service.configuration.friendly_config
end
end
end