Class: Barbeque::ExecutionLog

Inherits:
Object
  • Object
show all
Defined in:
lib/barbeque/execution_log.rb

Constant Summary collapse

DEFAULT_S3_BUCKET_NAME =
'barbeque'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.s3_clientObject



13
14
15
# File 'lib/barbeque/execution_log.rb', line 13

def s3_client
  @s3_client ||= Aws::S3::Client.new
end

Instance Method Details

#load(execution:) ⇒ Hash

Returns log.

Parameters:

Returns:

  • (Hash)

    log



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/barbeque/execution_log.rb', line 43

def load(execution:)
  return {} if execution.pending?

  message = get(execution, 'message.json')
  stdout = get(execution, 'stdout.txt')
  stderr = get(execution, 'stderr.txt')
  if message || stdout || stderr
    {
      'message' => message,
      'stdout' => stdout,
      'stderr' => stderr,
    }
  else
    nil
  end
end

#save_message(execution, message) ⇒ Object

Parameters:



20
21
22
# File 'lib/barbeque/execution_log.rb', line 20

def save_message(execution, message)
  put(execution, 'message.json', message.body.to_json)
end

#save_stdout_and_stderr(execution, stdout, stderr) ⇒ Object

Parameters:



27
28
29
30
# File 'lib/barbeque/execution_log.rb', line 27

def save_stdout_and_stderr(execution, stdout, stderr)
  put(execution, 'stdout.txt', stdout)
  put(execution, 'stderr.txt', stderr)
end

#try_save_stdout_and_stderr(execution, stdout, stderr) ⇒ Object

Parameters:



35
36
37
38
39
# File 'lib/barbeque/execution_log.rb', line 35

def try_save_stdout_and_stderr(execution, stdout, stderr)
  save_stdout_and_stderr(execution, stdout, stderr)
rescue Aws::S3::Errors::ServiceError => e
  ExceptionHandler.handle_exception(e)
end