Class: GoodData::Bricks::ExecutionResultMiddleware
- Inherits:
-
Middleware
- Object
- Middleware
- GoodData::Bricks::ExecutionResultMiddleware
- Defined in:
- lib/gooddata/bricks/middleware/execution_result_middleware.rb
Constant Summary collapse
- @@result_log_path =
nil
Instance Attribute Summary
Attributes inherited from Middleware
Class Method Summary collapse
-
.update_execution_result(status, message = "") ⇒ Object
Update process execution result when the script is executed inside a GDC ETL process execution (ruby bricks).
- .update_result(result, status = ExecutionStatus::ERROR) ⇒ Object
Instance Method Summary collapse
Methods inherited from Middleware
Methods included from Utils
Constructor Details
This class inherits a constructor from GoodData::Bricks::Middleware
Class Method Details
.update_execution_result(status, message = "") ⇒ Object
Update process execution result when the script is executed inside a GDC ETL process execution (ruby bricks). Ruby bricks should update execution result at the end of script with status=WARNING or OK and summary message if the script exits normally. If any fatal error, script should update execution result with status=ERROR and error message, then throw exception to notify GDC platform that the script terminated unexpectedly.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gooddata/bricks/middleware/execution_result_middleware.rb', line 31 def self.update_execution_result(status, = "") if status != ExecutionStatus::OK && status != ExecutionStatus::ERROR && status != ExecutionStatus::WARNING GoodData.logger.warn("Unknown execution status #{status}, ignored it.") end result = { executionResult: { status: status, message: } } update_result(result, status) end |
.update_result(result, status = ExecutionStatus::ERROR) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/gooddata/bricks/middleware/execution_result_middleware.rb', line 55 def self.update_result(result, status = ExecutionStatus::ERROR) if @@result_log_path.nil? GoodData.gd_logger&.warn("action=update_execution_result status=#{status} Not found execution result logger file.") return end File.open(@@result_log_path, 'w') { |file| file.write(JSON.pretty_generate(result)) } rescue Exception => e # rubocop:disable RescueException GoodData.gd_logger.error("action=update_execution_result status=error reason=#{e.message}") unless GoodData.gd_logger.nil? end |
Instance Method Details
#call(params) ⇒ Object
19 20 21 22 |
# File 'lib/gooddata/bricks/middleware/execution_result_middleware.rb', line 19 def call(params) result_log_path(params) @app.call(params) end |