38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/webhookdb/async/autoscaler.rb', line 38
def start
raise "already started" unless @instance.nil?
case self.provider
when "heroku"
opts = {heroku: Webhookdb::Heroku.client, max_additional_workers: self.max_additional_workers}
(opts[:app_id_or_app_name] = self.heroku_app_id_or_app_name) if
self.heroku_app_id_or_app_name
(opts[:formation_id_or_formation_type] = self.heroku_formation_id_or_formation_type) if
self.heroku_formation_id_or_formation_type
@impl = Amigo::Autoscaler::Heroku.new(**opts)
else
self._check_provider!
end
@instance = Amigo::Autoscaler.new(
poll_interval: self.poll_interval,
latency_threshold: self.latency_threshold,
hostname_regex: self.hostname_regex,
handlers: [self.method(:scale_up)],
alert_interval: self.alert_interval,
latency_restored_threshold: self.latency_restored_threshold,
latency_restored_handlers: [self.method(:scale_down)],
log: ->(level, msg, kw={}) { self.logger.send(level, msg, kw) },
)
return @instance.start
end
|