Class: Bumbleworks::Ruote
- Inherits:
-
Object
- Object
- Bumbleworks::Ruote
- Defined in:
- lib/bumbleworks/ruote.rb
Class Method Summary collapse
- .dashboard(options = {}) ⇒ Object
- .launch(name, *args) ⇒ Object
- .register_participants(&block) ⇒ Object
- .reset! ⇒ Object
- .set_catchall_if_needed ⇒ Object
-
.start_worker!(options = {}) ⇒ Object
Start a worker, which will begin polling for messages in the workflow storage.
- .storage ⇒ Object
Class Method Details
.dashboard(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bumbleworks/ruote.rb', line 6 def dashboard( = {}) @dashboard ||= begin context = if [:start_worker] == true ::Ruote::Worker.new(storage) else storage end ::Ruote::Dashboard.new(context) end end |
.launch(name, *args) ⇒ Object
40 41 42 |
# File 'lib/bumbleworks/ruote.rb', line 40 def launch(name, *args) dashboard.launch(dashboard.variables[name], *args) end |
.register_participants(&block) ⇒ Object
44 45 46 47 48 |
# File 'lib/bumbleworks/ruote.rb', line 44 def register_participants(&block) dashboard.register(&block) if block set_catchall_if_needed dashboard.participant_list end |
.reset! ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/bumbleworks/ruote.rb', line 70 def reset! if @storage @storage.purge! @storage.shutdown end @dashboard.shutdown if @dashboard && @dashboard.respond_to?(:shutdown) @storage = nil @dashboard = nil end |
.set_catchall_if_needed ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/bumbleworks/ruote.rb', line 50 def set_catchall_if_needed last_participant = dashboard.participant_list.last unless last_participant && last_participant.regex == "^.+$" && ["Ruote::StorageParticipant", "Bumbleworks::StorageParticipant"].include?(last_participant.classname) catchall = ::Ruote::ParticipantEntry.new(["^.+$", ["Bumbleworks::StorageParticipant", {}]]) dashboard.participant_list = dashboard.participant_list.push(catchall) end end |
.start_worker!(options = {}) ⇒ Object
Start a worker, which will begin polling for messages in the workflow storage. You can run multiple workers if you are using a storage that supports them (such as Sequel or Redis, but not Hash) - they all just have to be connected to the same storage, and be able to instantiate participants in the participant list.
32 33 34 35 36 37 38 |
# File 'lib/bumbleworks/ruote.rb', line 32 def start_worker!( = {}) @dashboard = nil dashboard(:start_worker => true) dashboard.noisy = [:verbose] == true dashboard.join if [:join] == true dashboard.worker end |
.storage ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bumbleworks/ruote.rb', line 59 def storage @storage ||= begin all_adapters = Bumbleworks.configuration.storage_adapters adapter = all_adapters.detect do |adapter| adapter.use?(Bumbleworks.storage) end raise UndefinedSetting, "Storage is missing or not supported. Supported: #{all_adapters.map(&:display_name).join(', ')}" unless adapter adapter.driver.new(Bumbleworks.storage) end end |