orchestr8 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb3a329867dcd0ded2c80e15c9429b242d94bb1da71ad08e0903710d9ebee189
4
+ data.tar.gz: '0251029e374e577258ccf68759bdee887cd6dffffbee0bdd29cd9d8dfdac3b56'
5
+ SHA512:
6
+ metadata.gz: b7f5204b20d5f299ccc5c9b7e2ead98e91dc8b6f3ba0ecb29c4b1648490f12def2578b24051c543ecee13b3950a4add6de849d5746bce7fc52b5330da23d4df3
7
+ data.tar.gz: bd5867c70e787185453a8487be232235c08c2100fd48b639813ad599fcff3cdf7040f75a38e1c5d288f82f254637f92a478726e87ff176104dd11bb302459b20
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Romulo Storel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,186 @@
1
+ # Orchestr8
2
+
3
+ DAG-based job workflow orchestration for Rails. Define multi-step workflows as directed acyclic graphs with parallel execution, dependency tracking, failure handling, and a built-in dashboard. No Redis required — all state lives in your database.
4
+
5
+ [![CI](https://github.com/romulostorel/orchestr8/actions/workflows/ci.yml/badge.svg)](https://github.com/romulostorel/orchestr8/actions/workflows/ci.yml)
6
+
7
+ ## What It Does
8
+
9
+ - Compose jobs into workflows with explicit dependencies
10
+ - Steps with no unmet dependencies run in parallel automatically
11
+ - Steps can pass output data to downstream steps
12
+ - Configurable failure handling per step (halt the workflow or continue)
13
+ - Built-in web dashboard with DAG visualization and real-time status updates
14
+ - Works with any Active Job backend (Solid Queue, Sidekiq, GoodJob, etc.)
15
+ - Test helper for synchronous, in-process workflow execution in specs
16
+
17
+ ## Installation
18
+
19
+ Add to your Gemfile:
20
+
21
+ ```ruby
22
+ gem "orchestr8"
23
+ ```
24
+
25
+ Run the migrations:
26
+
27
+ ```sh
28
+ bundle exec rails orchestr8:install:migrations
29
+ bundle exec rails db:migrate
30
+ ```
31
+
32
+ Mount the dashboard in `config/routes.rb`:
33
+
34
+ ```ruby
35
+ mount Orchestr8::Engine => "/orchestr8"
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### 1. Define a Workflow
41
+
42
+ ```ruby
43
+ # app/workflows/etl_workflow.rb
44
+ class EtlWorkflow < Orchestr8::Workflow
45
+ step :fetch, job: FetchDataJob
46
+ step :transform, job: TransformJob, after: :fetch
47
+ step :load, job: LoadJob, after: :transform
48
+ end
49
+ ```
50
+
51
+ ### 2. Add Stepable to Your Jobs
52
+
53
+ ```ruby
54
+ class FetchDataJob < ApplicationJob
55
+ include Orchestr8::Stepable
56
+
57
+ def perform(arguments)
58
+ data = fetch_data(arguments["url"])
59
+ output(data) # share data with downstream steps
60
+ end
61
+ end
62
+
63
+ class TransformJob < ApplicationJob
64
+ include Orchestr8::Stepable
65
+
66
+ def perform(arguments)
67
+ raw = payloads[:fetch] # read upstream output
68
+ output(transform(raw))
69
+ end
70
+ end
71
+ ```
72
+
73
+ ### 3. Run a Workflow
74
+
75
+ ```ruby
76
+ EtlWorkflow.create!(arguments: { "url" => "https://api.example.com/data" })
77
+ ```
78
+
79
+ Orchestr8 enqueues ready steps immediately, then re-evaluates and enqueues downstream steps as each step completes.
80
+
81
+ ## Step Options
82
+
83
+ | Option | Type | Default | Description |
84
+ |---|---|---|---|
85
+ | `job:` | Class | required | The Active Job class to perform |
86
+ | `after:` | Symbol or Array | `[]` | Step name(s) this step depends on |
87
+ | `on_failure:` | `:halt` / `:continue` | `:halt` | What to do when this step fails |
88
+ | `queue:` | String | nil | Override the queue name for this step |
89
+
90
+ ```ruby
91
+ class MyWorkflow < Orchestr8::Workflow
92
+ step :fetch, job: FetchJob, queue: "critical"
93
+ step :notify, job: NotifyJob, after: :fetch, on_failure: :continue
94
+ step :cleanup, job: CleanupJob, after: %i[fetch notify]
95
+ end
96
+ ```
97
+
98
+ ## Failure Handling
99
+
100
+ By default (`on_failure: :halt`), a failed step prevents downstream steps from running and marks the workflow as failed.
101
+
102
+ With `on_failure: :continue`, downstream steps still run even if this step fails. The failed step's output will be `nil` in `payloads`.
103
+
104
+ ```ruby
105
+ class ReportWorkflow < Orchestr8::Workflow
106
+ step :fetch_primary, job: FetchPrimaryJob
107
+ step :fetch_secondary, job: FetchSecondaryJob, on_failure: :continue
108
+ step :aggregate, job: AggregateJob, after: %i[fetch_primary fetch_secondary]
109
+ end
110
+ ```
111
+
112
+ ## Retry
113
+
114
+ Retry a single failed step:
115
+
116
+ ```ruby
117
+ step = workflow.steps.find_by(name: "transform")
118
+ step.retry!
119
+ ```
120
+
121
+ Retry all failed steps in a workflow:
122
+
123
+ ```ruby
124
+ workflow.retry!
125
+ ```
126
+
127
+ Both reset the step(s) to `pending` and re-trigger the scheduler immediately.
128
+
129
+ ## Dashboard
130
+
131
+ Mount the engine in your routes:
132
+
133
+ ```ruby
134
+ mount Orchestr8::Engine => "/orchestr8"
135
+ ```
136
+
137
+ The dashboard at `/orchestr8` lists all workflows with status and step progress. Each workflow's detail page shows a DAG visualization with real-time status updates via Turbo Streams.
138
+
139
+ ### Securing the Dashboard
140
+
141
+ Configure a base controller class that enforces authentication:
142
+
143
+ ```ruby
144
+ # config/initializers/orchestr8.rb
145
+ Orchestr8.configure do |config|
146
+ config.base_controller_class = "AdminController"
147
+ end
148
+ ```
149
+
150
+ The engine's controllers will inherit from that class, so any `before_action` defined there (e.g. `authenticate_admin!`) will apply automatically.
151
+
152
+ ## Testing
153
+
154
+ Use `Orchestr8::TestHelper` to execute workflows synchronously in specs without a real job backend:
155
+
156
+ ```ruby
157
+ # spec/rails_helper.rb (or in a specific spec)
158
+ require "orchestr8/test_helper"
159
+
160
+ RSpec.describe "My feature" do
161
+ include Orchestr8::TestHelper
162
+
163
+ it "completes the workflow inline" do
164
+ workflow = MyWorkflow.create!(arguments: { "key" => "value" })
165
+
166
+ expect(workflow.reload.status).to eq("completed")
167
+ expect(workflow.steps.all? { |s| s.status == "completed" }).to be true
168
+ end
169
+ end
170
+ ```
171
+
172
+ `Orchestr8::TestHelper` hooks into RSpec's `before`/`after` to enable and reset synchronous mode around each example. In synchronous mode the scheduler runs each job inline via `perform_now` and loops until all reachable steps are processed.
173
+
174
+ ## Works With
175
+
176
+ Orchestr8 uses Active Job and makes no assumptions about the backend.
177
+
178
+ | Backend | Gem | Notes |
179
+ |---|---|---|
180
+ | Solid Queue | `solid_queue` | Recommended for zero-Redis setups |
181
+ | Sidekiq | `sidekiq` | Set `config.active_job.queue_adapter = :sidekiq` |
182
+ | GoodJob | `good_job` | Postgres-native, supports concurrency controls |
183
+
184
+ ## License
185
+
186
+ MIT — see [LICENSE](LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
6
+ load "rails/tasks/engine.rake"
7
+ load "rails/tasks/statistics.rake"
8
+
9
+ require "rspec/core/rake_task"
10
+ RSpec::Core::RakeTask.new(:spec)
11
+ task default: :spec
@@ -0,0 +1,436 @@
1
+ /* Orchestr8 Web UI Styles */
2
+
3
+ *, *::before, *::after {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ .orchestr8 {
8
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
9
+ font-size: 14px;
10
+ color: #1a1a2e;
11
+ background: #f5f5f7;
12
+ min-height: 100vh;
13
+ }
14
+
15
+ .orchestr8-header {
16
+ background: #1a1a2e;
17
+ color: #fff;
18
+ padding: 16px 24px;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: space-between;
22
+ }
23
+
24
+ .orchestr8-header h1 {
25
+ margin: 0;
26
+ font-size: 20px;
27
+ font-weight: 700;
28
+ }
29
+
30
+ .orchestr8-header h1 a {
31
+ color: #fff;
32
+ text-decoration: none;
33
+ }
34
+
35
+ .orchestr8-header h1 a:hover {
36
+ text-decoration: underline;
37
+ }
38
+
39
+ .orchestr8-main {
40
+ padding: 24px;
41
+ max-width: 1280px;
42
+ margin: 0 auto;
43
+ }
44
+
45
+ /* Flash notices */
46
+ .orchestr8-notice {
47
+ background: #d1fae5;
48
+ border: 1px solid #6ee7b7;
49
+ border-radius: 6px;
50
+ color: #065f46;
51
+ padding: 12px 16px;
52
+ margin-bottom: 20px;
53
+ }
54
+
55
+ .orchestr8-alert {
56
+ background: #fee2e2;
57
+ border: 1px solid #fca5a5;
58
+ border-radius: 6px;
59
+ color: #991b1b;
60
+ padding: 12px 16px;
61
+ margin-bottom: 20px;
62
+ }
63
+
64
+ /* Filters */
65
+ .orchestr8-filters {
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 12px;
69
+ margin-bottom: 20px;
70
+ flex-wrap: wrap;
71
+ }
72
+
73
+ .orchestr8-filters label {
74
+ font-weight: 600;
75
+ color: #374151;
76
+ }
77
+
78
+ .orchestr8-filters select {
79
+ padding: 8px 12px;
80
+ border: 1px solid #d1d5db;
81
+ border-radius: 6px;
82
+ background: #fff;
83
+ font-size: 14px;
84
+ cursor: pointer;
85
+ color: #374151;
86
+ }
87
+
88
+ .orchestr8-filters select:focus {
89
+ outline: none;
90
+ border-color: #6366f1;
91
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
92
+ }
93
+
94
+ /* Table */
95
+ .orchestr8-table {
96
+ width: 100%;
97
+ border-collapse: collapse;
98
+ background: #fff;
99
+ border-radius: 8px;
100
+ overflow: hidden;
101
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
102
+ }
103
+
104
+ .orchestr8-table thead {
105
+ background: #f9fafb;
106
+ }
107
+
108
+ .orchestr8-table th {
109
+ padding: 12px 16px;
110
+ text-align: left;
111
+ font-weight: 600;
112
+ color: #6b7280;
113
+ font-size: 12px;
114
+ text-transform: uppercase;
115
+ letter-spacing: 0.05em;
116
+ border-bottom: 1px solid #e5e7eb;
117
+ }
118
+
119
+ .orchestr8-table td {
120
+ padding: 12px 16px;
121
+ border-bottom: 1px solid #f3f4f6;
122
+ color: #374151;
123
+ }
124
+
125
+ .orchestr8-table tbody tr:last-child td {
126
+ border-bottom: none;
127
+ }
128
+
129
+ .orchestr8-table tbody tr:hover {
130
+ background: #f9fafb;
131
+ cursor: pointer;
132
+ }
133
+
134
+ .orchestr8-table a {
135
+ color: #6366f1;
136
+ text-decoration: none;
137
+ font-weight: 500;
138
+ }
139
+
140
+ .orchestr8-table a:hover {
141
+ text-decoration: underline;
142
+ }
143
+
144
+ /* Badges */
145
+ .orchestr8-badge {
146
+ display: inline-flex;
147
+ align-items: center;
148
+ padding: 3px 10px;
149
+ border-radius: 9999px;
150
+ font-size: 12px;
151
+ font-weight: 600;
152
+ text-transform: lowercase;
153
+ }
154
+
155
+ .orchestr8-badge--pending {
156
+ background: #f3f4f6;
157
+ color: #6b7280;
158
+ }
159
+
160
+ .orchestr8-badge--enqueued {
161
+ background: #ede9fe;
162
+ color: #7c3aed;
163
+ }
164
+
165
+ .orchestr8-badge--running {
166
+ background: #dbeafe;
167
+ color: #1d4ed8;
168
+ }
169
+
170
+ .orchestr8-badge--completed {
171
+ background: #d1fae5;
172
+ color: #065f46;
173
+ }
174
+
175
+ .orchestr8-badge--failed {
176
+ background: #fee2e2;
177
+ color: #991b1b;
178
+ }
179
+
180
+ /* Progress bar */
181
+ .orchestr8-progress {
182
+ display: flex;
183
+ align-items: center;
184
+ gap: 8px;
185
+ }
186
+
187
+ .orchestr8-progress-bar {
188
+ flex: 1;
189
+ height: 8px;
190
+ background: #e5e7eb;
191
+ border-radius: 9999px;
192
+ overflow: hidden;
193
+ min-width: 80px;
194
+ }
195
+
196
+ .orchestr8-progress-fill {
197
+ height: 100%;
198
+ background: #6366f1;
199
+ border-radius: 9999px;
200
+ transition: width 0.3s ease;
201
+ }
202
+
203
+ .orchestr8-progress-text {
204
+ font-size: 12px;
205
+ color: #6b7280;
206
+ white-space: nowrap;
207
+ }
208
+
209
+ /* Buttons */
210
+ .orchestr8-btn {
211
+ display: inline-flex;
212
+ align-items: center;
213
+ gap: 6px;
214
+ padding: 8px 16px;
215
+ border-radius: 6px;
216
+ font-size: 14px;
217
+ font-weight: 500;
218
+ cursor: pointer;
219
+ border: none;
220
+ text-decoration: none;
221
+ transition: background 0.15s, box-shadow 0.15s;
222
+ }
223
+
224
+ .orchestr8-btn--primary {
225
+ background: #6366f1;
226
+ color: #fff;
227
+ }
228
+
229
+ .orchestr8-btn--primary:hover {
230
+ background: #4f46e5;
231
+ color: #fff;
232
+ }
233
+
234
+ .orchestr8-btn--secondary {
235
+ background: #f3f4f6;
236
+ color: #374151;
237
+ }
238
+
239
+ .orchestr8-btn--secondary:hover {
240
+ background: #e5e7eb;
241
+ color: #374151;
242
+ }
243
+
244
+ .orchestr8-btn--danger {
245
+ background: #fee2e2;
246
+ color: #991b1b;
247
+ }
248
+
249
+ .orchestr8-btn--danger:hover {
250
+ background: #fecaca;
251
+ color: #7f1d1d;
252
+ }
253
+
254
+ .orchestr8-btn--sm {
255
+ padding: 4px 10px;
256
+ font-size: 12px;
257
+ }
258
+
259
+ /* Page header */
260
+ .orchestr8-page-header {
261
+ display: flex;
262
+ align-items: center;
263
+ justify-content: space-between;
264
+ margin-bottom: 24px;
265
+ flex-wrap: wrap;
266
+ gap: 12px;
267
+ }
268
+
269
+ .orchestr8-page-header h2 {
270
+ margin: 0;
271
+ font-size: 22px;
272
+ font-weight: 700;
273
+ color: #1a1a2e;
274
+ }
275
+
276
+ /* Detail header */
277
+ .orchestr8-detail-header {
278
+ background: #fff;
279
+ border-radius: 8px;
280
+ padding: 20px 24px;
281
+ margin-bottom: 24px;
282
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
283
+ display: flex;
284
+ align-items: center;
285
+ gap: 16px;
286
+ flex-wrap: wrap;
287
+ }
288
+
289
+ .orchestr8-detail-header h2 {
290
+ margin: 0;
291
+ font-size: 20px;
292
+ font-weight: 700;
293
+ color: #1a1a2e;
294
+ flex: 1;
295
+ }
296
+
297
+ .orchestr8-detail-meta {
298
+ font-size: 12px;
299
+ color: #6b7280;
300
+ margin-top: 4px;
301
+ }
302
+
303
+ /* DAG visualization */
304
+ .orchestr8-dag {
305
+ background: #fff;
306
+ border-radius: 8px;
307
+ padding: 24px;
308
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
309
+ overflow-x: auto;
310
+ }
311
+
312
+ .orchestr8-dag-layers {
313
+ display: flex;
314
+ align-items: center;
315
+ gap: 0;
316
+ min-width: fit-content;
317
+ }
318
+
319
+ .orchestr8-dag-layer {
320
+ display: flex;
321
+ flex-direction: column;
322
+ align-items: center;
323
+ gap: 12px;
324
+ padding: 0 8px;
325
+ }
326
+
327
+ .orchestr8-dag-arrow {
328
+ display: flex;
329
+ align-items: center;
330
+ color: #d1d5db;
331
+ font-size: 24px;
332
+ padding: 0 4px;
333
+ align-self: center;
334
+ }
335
+
336
+ /* Step nodes */
337
+ .orchestr8-node {
338
+ border: 2px solid #e5e7eb;
339
+ border-radius: 8px;
340
+ padding: 12px 16px;
341
+ min-width: 180px;
342
+ max-width: 220px;
343
+ background: #fff;
344
+ transition: border-color 0.2s, box-shadow 0.2s;
345
+ }
346
+
347
+ .orchestr8-node:hover {
348
+ box-shadow: 0 2px 8px rgba(0,0,0,0.12);
349
+ }
350
+
351
+ .orchestr8-node--pending {
352
+ border-color: #d1d5db;
353
+ background: #f9fafb;
354
+ }
355
+
356
+ .orchestr8-node--enqueued {
357
+ border-color: #a78bfa;
358
+ background: #faf5ff;
359
+ }
360
+
361
+ .orchestr8-node--running {
362
+ border-color: #60a5fa;
363
+ background: #eff6ff;
364
+ animation: orchestr8-pulse 2s infinite;
365
+ }
366
+
367
+ .orchestr8-node--completed {
368
+ border-color: #34d399;
369
+ background: #f0fdf4;
370
+ }
371
+
372
+ .orchestr8-node--failed {
373
+ border-color: #f87171;
374
+ background: #fff5f5;
375
+ }
376
+
377
+ @keyframes orchestr8-pulse {
378
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.4); }
379
+ 50% { box-shadow: 0 0 0 6px rgba(96, 165, 250, 0); }
380
+ }
381
+
382
+ .orchestr8-node-header {
383
+ display: flex;
384
+ align-items: center;
385
+ justify-content: space-between;
386
+ margin-bottom: 8px;
387
+ }
388
+
389
+ .orchestr8-node-name {
390
+ font-weight: 700;
391
+ font-size: 13px;
392
+ color: #1a1a2e;
393
+ }
394
+
395
+ .orchestr8-node-job {
396
+ font-size: 11px;
397
+ color: #6b7280;
398
+ margin-bottom: 8px;
399
+ word-break: break-all;
400
+ }
401
+
402
+ .orchestr8-node-meta {
403
+ display: flex;
404
+ align-items: center;
405
+ justify-content: space-between;
406
+ font-size: 11px;
407
+ color: #9ca3af;
408
+ }
409
+
410
+ .orchestr8-node-error {
411
+ margin-top: 8px;
412
+ font-size: 11px;
413
+ color: #ef4444;
414
+ background: #fee2e2;
415
+ border-radius: 4px;
416
+ padding: 4px 8px;
417
+ word-break: break-word;
418
+ }
419
+
420
+ .orchestr8-node-actions {
421
+ margin-top: 10px;
422
+ display: flex;
423
+ gap: 6px;
424
+ }
425
+
426
+ /* Empty state */
427
+ .orchestr8-empty {
428
+ text-align: center;
429
+ padding: 48px 24px;
430
+ color: #9ca3af;
431
+ }
432
+
433
+ .orchestr8-empty p {
434
+ font-size: 16px;
435
+ margin: 0;
436
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orchestr8
4
+ class ApplicationController < ::ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orchestr8
4
+ class StepsController < ApplicationController
5
+ def retry
6
+ workflow = Workflow.find(params[:workflow_id])
7
+ step = workflow.steps.find(params[:id])
8
+ step.retry!
9
+ redirect_to workflow_path(workflow), notice: "Retrying step: #{step.name}"
10
+ end
11
+ end
12
+ end