Module: Vx::Worker

Extended by:
Worker
Included in:
Worker
Defined in:
lib/vx/worker.rb,
lib/vx/worker/cli.rb,
lib/vx/worker/job.rb,
lib/vx/worker/local.rb,
lib/vx/worker/docker.rb,
lib/vx/worker/version.rb,
lib/vx/worker/configuration.rb,
lib/vx/worker/helper/config.rb,
lib/vx/worker/helper/logger.rb,
lib/vx/worker/middlewares/log_job.rb,
lib/vx/worker/middlewares/timeout.rb,
lib/vx/worker/middlewares/run_script.rb,
lib/vx/worker/consumers/jobs_consumer.rb,
lib/vx/worker/consumers/job_logs_consumer.rb,
lib/vx/worker/middlewares/start_connector.rb,
lib/vx/worker/consumers/job_status_consumer.rb,
lib/vx/worker/middlewares/update_job_status.rb

Defined Under Namespace

Modules: Helper Classes: CLI, Configuration, Docker, Job, JobLogsConsumer, JobStatusConsumer, JobsConsumer, Local, LogJob, RunScript, StartConnector, Timeout, UpdateJobStatus

Constant Summary collapse

VERSION =
"0.2.1"
@@root =
Pathname.new File.expand_path('../../..', __FILE__)
@@config_mutex =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#configObject



50
51
52
53
54
55
56
# File 'lib/vx/worker.rb', line 50

def config
  @config ||= begin
    @@config_mutex.synchronize do
      Configuration.new
    end
  end
end

#configure {|config| ... } ⇒ Object

Yields:



45
46
47
48
# File 'lib/vx/worker.rb', line 45

def configure
  yield config
  config
end

#initialize!Object



76
77
78
79
80
# File 'lib/vx/worker.rb', line 76

def initialize!
  root.join("lib/vx/worker/initializers").children.each do |e|
    require e
  end
end

#loggerObject



37
38
39
40
41
42
43
# File 'lib/vx/worker.rb', line 37

def logger
  if ENV['CI_WORKER_SILENT']
    config.null_logger
  else
    config.logger
  end
end

#perform(job, path_prefix) ⇒ Object



62
63
64
65
66
# File 'lib/vx/worker.rb', line 62

def perform(job, path_prefix)
  rs = run_class.new(job, path_prefix).perform
  job.release
  rs
end

#reset_config!Object



72
73
74
# File 'lib/vx/worker.rb', line 72

def reset_config!
  @config = nil
end

#rootObject



58
59
60
# File 'lib/vx/worker.rb', line 58

def root
  @@root
end

#run_classObject



68
69
70
# File 'lib/vx/worker.rb', line 68

def run_class
  self.const_get(config.run.to_s.camelize)
end