Class: Floe::Runner
- Inherits:
-
Object
- Object
- Floe::Runner
- Defined in:
- lib/floe/runner.rb
Direct Known Subclasses
Constant Summary collapse
- OUTPUT_MARKER =
"__FLOE_OUTPUT__\n"
Class Method Summary collapse
Instance Method Summary collapse
-
#cleanup(_runner_context) ⇒ void
Cleanup runner context resources Called after a task is completed and the runner_context is no longer needed.
-
#initialize(_options = {}) ⇒ Runner
constructor
rubocop:disable Style/RedundantInitialize.
-
#output(_runner_context) ⇒ String, Hash
For a successful task, return the output.
-
#run_async!(_resource, _env = {}, _secrets = {}, _context = {}) ⇒ Hash
Run a command asynchronously and create a runner_context.
-
#running?(_runner_context) ⇒ Boolean
check runner_contet to determine if the task is still running or completed.
-
#status!(_runner_context) ⇒ void
update the runner_context.
-
#success?(_runner_context) ⇒ Boolean
For a non-running? task, check if it was successful.
Constructor Details
#initialize(_options = {}) ⇒ Runner
rubocop:disable Style/RedundantInitialize
7 8 |
# File 'lib/floe/runner.rb', line 7 def initialize( = {}) # rubocop:disable Style/RedundantInitialize end |
Class Method Details
.for_resource(resource) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/floe/runner.rb', line 22 def for_resource(resource) raise ArgumentError, "resource cannot be nil" if resource.nil? scheme = resource.split("://").first resolve_scheme(scheme) || raise(ArgumentError, "Invalid resource scheme [#{scheme}]") end |
.register_scheme(scheme, klass_or_proc) ⇒ Object
12 13 14 |
# File 'lib/floe/runner.rb', line 12 def register_scheme(scheme, klass_or_proc) @runners[scheme] = klass_or_proc end |
Instance Method Details
#cleanup(_runner_context) ⇒ void
This method returns an undefined value.
Cleanup runner context resources Called after a task is completed and the runner_context is no longer needed.
72 73 74 |
# File 'lib/floe/runner.rb', line 72 def cleanup(_runner_context) raise NotImplementedError, "Must be implemented in a subclass" end |
#output(_runner_context) ⇒ String, Hash
For a successful task, return the output
64 65 66 |
# File 'lib/floe/runner.rb', line 64 def output(_runner_context) raise NotImplementedError, "Must be implemented in a subclass" end |
#run_async!(_resource, _env = {}, _secrets = {}, _context = {}) ⇒ Hash
Run a command asynchronously and create a runner_context
32 33 34 |
# File 'lib/floe/runner.rb', line 32 def run_async!(_resource, _env = {}, _secrets = {}, _context = {}) raise NotImplementedError, "Must be implemented in a subclass" end |
#running?(_runner_context) ⇒ Boolean
check runner_contet to determine if the task is still running or completed
48 49 50 |
# File 'lib/floe/runner.rb', line 48 def running?(_runner_context) raise NotImplementedError, "Must be implemented in a subclass" end |
#status!(_runner_context) ⇒ void
This method returns an undefined value.
update the runner_context
39 40 41 |
# File 'lib/floe/runner.rb', line 39 def status!(_runner_context) raise NotImplementedError, "Must be implemented in a subclass" end |
#success?(_runner_context) ⇒ Boolean
For a non-running? task, check if it was successful
57 58 59 |
# File 'lib/floe/runner.rb', line 57 def success?(_runner_context) raise NotImplementedError, "Must be implemented in a subclass" end |