Class: Acfs::Runner Private
- Inherits:
-
Object
- Object
- Acfs::Runner
- Includes:
- Service::Middleware, Telemetry
- Defined in:
- lib/acfs/runner.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #adapter ⇒ Object readonly private
Instance Method Summary collapse
- #clear ⇒ Object private
-
#enqueue(operation) ⇒ Object
private
Enqueue operation to be run later.
-
#initialize(adapter) ⇒ Runner
constructor
private
A new instance of Runner.
-
#process(operation) ⇒ Object
private
Process an operation.
-
#queue ⇒ Object
private
List of current queued operations.
-
#run(operation) ⇒ Object
private
Run operation right now skipping queue.
-
#running? ⇒ Boolean
private
Return true if queued operations are currently processed.
-
#start ⇒ Object
private
Start processing queued operations.
Methods included from Telemetry
Constructor Details
#initialize(adapter) ⇒ Runner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Runner.
14 15 16 17 |
# File 'lib/acfs/runner.rb', line 14 def initialize(adapter) @adapter = adapter @running = false end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/acfs/runner.rb', line 12 def adapter @adapter end |
Instance Method Details
#clear ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 |
# File 'lib/acfs/runner.rb', line 75 def clear queue.clear adapter.abort @running = false end |
#enqueue(operation) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enqueue operation to be run later.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/acfs/runner.rb', line 45 def enqueue(operation) tracer.in_span('acfs.runner.enqueue') do ::ActiveSupport::Notifications.instrument('acfs.runner.enqueue', operation: operation) do if running? operation_request(operation) {|req| adapter.queue req } else queue << operation end end end end |
#process(operation) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Process an operation. Synchronous operations will be run and parallel operations will be queued.
22 23 24 25 |
# File 'lib/acfs/runner.rb', line 22 def process(operation) ::ActiveSupport::Notifications.instrument('acfs.operation.before_process', operation: operation) operation.synchronous? ? run(operation) : enqueue(operation) end |
#queue ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
List of current queued operations.
39 40 41 |
# File 'lib/acfs/runner.rb', line 39 def queue @queue ||= [] end |
#run(operation) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run operation right now skipping queue.
29 30 31 32 33 34 35 |
# File 'lib/acfs/runner.rb', line 29 def run(operation) tracer.in_span('acfs.runner.sync_run') do ::ActiveSupport::Notifications.instrument('acfs.runner.sync_run', operation: operation) do operation_request(operation) {|req| adapter.run req } end end end |
#running? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return true if queued operations are currently processed.
59 60 61 |
# File 'lib/acfs/runner.rb', line 59 def running? @running end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Start processing queued operations.
65 66 67 68 69 70 71 72 73 |
# File 'lib/acfs/runner.rb', line 65 def start return if running? enqueue_operations start_all rescue StandardError queue.clear raise end |