Class: Vx::Worker::Job
- Inherits:
-
Object
- Object
- Vx::Worker::Job
- Includes:
- Helper::Logger
- Defined in:
- lib/vx/worker/job.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#output_counter ⇒ Object
readonly
Returns the value of attribute output_counter.
Instance Method Summary collapse
- #add_command_to_output(cmd) ⇒ Object
- #add_to_output(str) ⇒ Object
- #add_trace_to_output(log) ⇒ Object
-
#initialize(perform_job_message) ⇒ Job
constructor
A new instance of Job.
- #publish_job_log_message(str) ⇒ Object
- #release ⇒ Object
Methods included from Helper::Logger
Constructor Details
#initialize(perform_job_message) ⇒ Job
Returns a new instance of Job.
12 13 14 15 16 |
# File 'lib/vx/worker/job.rb', line 12 def initialize() @output_counter = 0 = @output = Common::OutputBuffer.new(&method(:publish_job_log_message)) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/vx/worker/job.rb', line 10 def end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/vx/worker/job.rb', line 10 def output @output end |
#output_counter ⇒ Object (readonly)
Returns the value of attribute output_counter.
10 11 12 |
# File 'lib/vx/worker/job.rb', line 10 def output_counter @output_counter end |
Instance Method Details
#add_command_to_output(cmd) ⇒ Object
23 24 25 |
# File 'lib/vx/worker/job.rb', line 23 def add_command_to_output(cmd) add_to_output "$ #{cmd}\n" end |
#add_to_output(str) ⇒ Object
18 19 20 21 |
# File 'lib/vx/worker/job.rb', line 18 def add_to_output(str) output << str logger.debug str.strip if logger.level == 0 end |
#add_trace_to_output(log) ⇒ Object
27 28 29 |
# File 'lib/vx/worker/job.rb', line 27 def add_trace_to_output(log) add_to_output log.split(/\n/).map{|i| " ===> #{i}\n" }.join end |
#publish_job_log_message(str) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vx/worker/job.rb', line 35 def (str) @output_counter += 1 log = Message::JobLog.new( build_id: .id, job_id: .job_id, tm: output_counter, log: str ) JobLogsConsumer.publish log log end |
#release ⇒ Object
31 32 33 |
# File 'lib/vx/worker/job.rb', line 31 def release output.close end |