Module: Exekutor
- Defined in:
- lib/exekutor.rb,
lib/exekutor/job.rb,
lib/exekutor/hook.rb,
lib/exekutor/queue.rb,
lib/exekutor/worker.rb,
lib/exekutor/cleanup.rb,
lib/exekutor/plugins.rb,
lib/exekutor/version.rb,
lib/exekutor/job_error.rb,
lib/exekutor/info/worker.rb,
lib/exekutor/job_options.rb,
lib/exekutor/asynchronous.rb,
lib/exekutor/configuration.rb,
lib/exekutor/internal/hooks.rb,
lib/exekutor/internal/logger.rb,
lib/exekutor/internal/cli/app.rb,
lib/exekutor/internal/cli/info.rb,
lib/exekutor/internal/executor.rb,
lib/exekutor/internal/listener.rb,
lib/exekutor/internal/provider.rb,
lib/exekutor/internal/reserver.rb,
lib/exekutor/plugins/appsignal.rb,
lib/exekutor/internal/callbacks.rb,
lib/exekutor/internal/cli/daemon.rb,
lib/exekutor/internal/executable.rb,
lib/exekutor/internal/base_record.rb,
lib/exekutor/internal/cli/cleanup.rb,
lib/exekutor/internal/cli/manager.rb,
lib/exekutor/internal/status_server.rb,
lib/exekutor/internal/database_connection.rb,
lib/generators/exekutor/install_generator.rb,
lib/exekutor/internal/configuration_builder.rb,
lib/exekutor/internal/cli/application_loader.rb,
lib/exekutor/internal/cli/default_option_value.rb,
lib/generators/exekutor/configuration_generator.rb
Overview
The Exekutor namespace
Defined Under Namespace
Modules: Asynchronous, Hook, Info, Internal, JobOptions, Plugins Classes: Cleanup, Configuration, ConfigurationGenerator, DiscardJob, Error, InstallGenerator, Job, JobError, Queue, Worker
Constant Summary collapse
- VERSION =
The current version of Exekutor
"0.1.2"
Instance Attribute Summary collapse
-
#hooks ⇒ Internal::Hooks
readonly
The hooks for exekutor.
Class Method Summary collapse
- .config ⇒ Object
- .configure(opts = nil, &block) ⇒ Object
- .load_plugin(name) ⇒ Object
-
.logger=(logger) ⇒ Object
Sets the logger.
-
.on_fatal_error(error, message = nil) ⇒ Object
Prints the error to STDERR and the log, and calls the :on_fatal_error hooks.
-
.print_error(error, message = nil) ⇒ void
Prints the error in the log and to STDERR (unless Configuration#quiet? is true).
-
.say(*args) ⇒ Object
Prints a message to STDOUT, unless Configuration#quiet? is true.
Instance Method Summary collapse
-
#logger ⇒ ActiveSupport::TaggedLogging
Gets the logger.
Instance Attribute Details
#hooks ⇒ Internal::Hooks (readonly)
Returns The hooks for exekutor.
89 |
# File 'lib/exekutor/internal/hooks.rb', line 89 mattr_reader :hooks, default: Internal::Hooks.new |
Class Method Details
.config ⇒ Object
406 407 408 |
# File 'lib/exekutor/configuration.rb', line 406 def self.config @config ||= Exekutor::Configuration.new end |
.configure(opts = nil, &block) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/exekutor/configuration.rb', line 410 def self.configure(opts = nil, &block) raise ArgumentError, "either opts or a block must be given" unless opts || block if opts raise ArgumentError, "opts must be a Hash" unless opts.is_a?(Hash) config.set(**opts) end if block if block.arity.zero? instance_eval(&block) else yield config end end self end |
.load_plugin(name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/exekutor/plugins.rb', line 10 def self.load_plugin(name) unless File.exist? File.join(__dir__, "plugins/#{name}.rb") raise Plugins::LoadError, "The #{name} plugin does not exist. Have you spelled it correctly?" end require_relative "plugins/#{name}" end |
.logger=(logger) ⇒ Object
Sets the logger
67 68 69 70 71 72 73 74 75 |
# File 'lib/exekutor/internal/logger.rb', line 67 def self.logger=(logger) raise ArgumentError, "logger must be a logger" unless logger.is_a? Logger @logger = if logger.is_a? ActiveSupport::TaggedLogging logger else ActiveSupport::TaggedLogging.new logger end end |
.on_fatal_error(error, message = nil) ⇒ Object
Prints the error to STDERR and the log, and calls the :on_fatal_error hooks.
51 52 53 54 55 56 57 58 59 |
# File 'lib/exekutor/internal/hooks.rb', line 51 def self.on_fatal_error(error, = nil) Exekutor.print_error(error, ) return if defined?(@calling_fatal_error_hook) && @calling_fatal_error_hook @calling_fatal_error_hook = true Internal::Hooks.on(:fatal_error, error) ensure @calling_fatal_error_hook = false end |
.print_error(error, message = nil) ⇒ void
This method returns an undefined value.
Prints the error in the log and to STDERR (unless Exekutor::Configuration#quiet? is true)
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/exekutor/internal/logger.rb', line 48 def self.print_error(error, = nil) error = strferr(error) unless config.quiet? warn Rainbow().bright.red if warn Rainbow(error).red end if config.quiet? || !ActiveSupport::Logger.logger_outputs_to?(logger, $stdout) logger.error if logger.error error end nil end |
.say(*args) ⇒ Object
Prints a message to STDOUT, unless Exekutor::Configuration#quiet? is true
40 41 42 |
# File 'lib/exekutor/internal/logger.rb', line 40 def self.say(*args) puts(*args) unless config.quiet? # rubocop:disable Rails/Output end |
Instance Method Details
#logger ⇒ ActiveSupport::TaggedLogging
Gets the logger
63 |
# File 'lib/exekutor/internal/logger.rb', line 63 mattr_reader :logger, default: ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new($stdout)) |