lib/heartcheck.rb in heartcheck-1.0.7 vs lib/heartcheck.rb in heartcheck-1.0.8
- old
+ new
@@ -11,10 +11,13 @@
class << self
# @attr [Array<Checks>] the checks to use when checking
attr_accessor :checks
+ # @attr [Heartcheck::Executors::Base] the checks executor backend
+ attr_accessor :executor
+
# @attr_writer [Object] change the default logger
attr_writer :logger
# Is used to log some messages when checking if the logger
# is not set it's returns de default_logger.
@@ -88,9 +91,28 @@
# filter checks that has some information
#
# @return [Array<Check>] checks that respond to :info
def info_checks
checks.select { |ctx| ctx.respond_to?(:info) }
+ end
+
+ # an executor class that respond to dispatch(checkers)
+ #
+ # @return [Heartcheck::Executors::Base]
+ def executor
+ @executor ||= Heartcheck::Executors::Base.new
+ end
+
+
+ # change current executor to a threaded implementation
+ # requires 'concurrent-ruby'
+ #
+ # @return [Hearcheck::Executors::Threaded]
+ def use_threaded_executor!
+ require "concurrent"
+ require "heartcheck/executors/threaded"
+
+ self.executor = Heartcheck::Executors::Threaded.new
end
private
# if no logger is setted we create an instance