good_pipeline 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 +7 -0
- data/CHANGELOG.md +16 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +217 -0
- data/Rakefile +20 -0
- data/app/controllers/good_pipeline/application_controller.rb +9 -0
- data/app/controllers/good_pipeline/frontends_controller.rb +31 -0
- data/app/controllers/good_pipeline/pipelines_controller.rb +57 -0
- data/app/frontend/good_pipeline/style.css +518 -0
- data/app/helpers/good_pipeline/pipelines_helper.rb +119 -0
- data/app/jobs/good_pipeline/pipeline_callback_job.rb +52 -0
- data/app/jobs/good_pipeline/pipeline_reconciliation_job.rb +10 -0
- data/app/jobs/good_pipeline/step_finished_job.rb +10 -0
- data/app/models/good_pipeline/chain_record.rb +18 -0
- data/app/models/good_pipeline/dependency_record.rb +23 -0
- data/app/models/good_pipeline/pipeline_record.rb +73 -0
- data/app/models/good_pipeline/step_record.rb +74 -0
- data/app/views/good_pipeline/pipelines/_chain_links.html.erb +30 -0
- data/app/views/good_pipeline/pipelines/_pagination.html.erb +24 -0
- data/app/views/good_pipeline/pipelines/_pipeline_row.html.erb +7 -0
- data/app/views/good_pipeline/pipelines/_steps_table.html.erb +33 -0
- data/app/views/good_pipeline/pipelines/definitions.html.erb +49 -0
- data/app/views/good_pipeline/pipelines/index.html.erb +43 -0
- data/app/views/good_pipeline/pipelines/show.html.erb +40 -0
- data/app/views/layouts/good_pipeline/application.html.erb +40 -0
- data/config/routes.rb +13 -0
- data/demo/Rakefile +5 -0
- data/demo/app/jobs/always_failing_job.rb +12 -0
- data/demo/app/jobs/application_job.rb +4 -0
- data/demo/app/jobs/cleanup_job.rb +5 -0
- data/demo/app/jobs/download_job.rb +5 -0
- data/demo/app/jobs/failing_job.rb +12 -0
- data/demo/app/jobs/publish_job.rb +5 -0
- data/demo/app/jobs/retryable_job.rb +19 -0
- data/demo/app/jobs/thumbnail_job.rb +5 -0
- data/demo/app/jobs/transcode_job.rb +5 -0
- data/demo/app/pipelines/analytics_pipeline.rb +7 -0
- data/demo/app/pipelines/archive_pipeline.rb +7 -0
- data/demo/app/pipelines/continue_test_pipeline.rb +11 -0
- data/demo/app/pipelines/halt_test_pipeline.rb +10 -0
- data/demo/app/pipelines/notification_pipeline.rb +7 -0
- data/demo/app/pipelines/test_pipeline.rb +5 -0
- data/demo/app/pipelines/video_processing_pipeline.rb +14 -0
- data/demo/bin/rails +6 -0
- data/demo/config/application.rb +18 -0
- data/demo/config/boot.rb +5 -0
- data/demo/config/database.yml +15 -0
- data/demo/config/environment.rb +5 -0
- data/demo/config/environments/development.rb +9 -0
- data/demo/config/environments/test.rb +10 -0
- data/demo/config/routes.rb +6 -0
- data/demo/config.ru +5 -0
- data/demo/db/migrate/20260319205325_create_good_jobs.rb +112 -0
- data/demo/db/migrate/20260319205326_create_good_pipeline_tables.rb +53 -0
- data/demo/db/seeds.rb +153 -0
- data/demo/test/good_pipeline/test_chain_record.rb +29 -0
- data/demo/test/good_pipeline/test_cleanup.rb +93 -0
- data/demo/test/good_pipeline/test_coordinator.rb +286 -0
- data/demo/test/good_pipeline/test_dependency_record.rb +46 -0
- data/demo/test/good_pipeline/test_failure_metadata.rb +77 -0
- data/demo/test/good_pipeline/test_introspection.rb +46 -0
- data/demo/test/good_pipeline/test_pipeline_callback_job.rb +132 -0
- data/demo/test/good_pipeline/test_pipeline_reconciliation_job.rb +33 -0
- data/demo/test/good_pipeline/test_pipeline_record.rb +183 -0
- data/demo/test/good_pipeline/test_runner.rb +86 -0
- data/demo/test/good_pipeline/test_step_finished_job.rb +37 -0
- data/demo/test/good_pipeline/test_step_record.rb +208 -0
- data/demo/test/integration/test_concurrent_fan_in.rb +109 -0
- data/demo/test/integration/test_end_to_end.rb +89 -0
- data/demo/test/integration/test_enqueue_atomicity.rb +59 -0
- data/demo/test/integration/test_pipeline_chaining.rb +183 -0
- data/demo/test/integration/test_retry_scenarios.rb +90 -0
- data/demo/test/integration/test_step_finished_idempotency.rb +38 -0
- data/demo/test/test_helper.rb +71 -0
- data/dev-docker-compose.yml +16 -0
- data/docs/.vitepress/config.mts +66 -0
- data/docs/.vitepress/theme/custom.css +21 -0
- data/docs/.vitepress/theme/index.ts +4 -0
- data/docs/architecture.md +184 -0
- data/docs/callbacks.md +66 -0
- data/docs/cleanup.md +45 -0
- data/docs/dag-validation.md +88 -0
- data/docs/dashboard.md +66 -0
- data/docs/defining-pipelines.md +167 -0
- data/docs/failure-strategies.md +138 -0
- data/docs/getting-started.md +77 -0
- data/docs/index.md +23 -0
- data/docs/introduction.md +42 -0
- data/docs/monitoring.md +103 -0
- data/docs/package-lock.json +2510 -0
- data/docs/package.json +11 -0
- data/docs/pipeline-chaining.md +104 -0
- data/docs/public/screenshots/definitions.png +0 -0
- data/docs/public/screenshots/index.png +0 -0
- data/docs/public/screenshots/show.png +0 -0
- data/docs/screenshots/definitions.png +0 -0
- data/docs/screenshots/index.png +0 -0
- data/docs/screenshots/show.png +0 -0
- data/lib/generators/good_pipeline/install/install_generator.rb +20 -0
- data/lib/generators/good_pipeline/install/templates/create_good_pipeline_tables.rb.erb +51 -0
- data/lib/good_pipeline/chain.rb +54 -0
- data/lib/good_pipeline/chain_coordinator.rb +53 -0
- data/lib/good_pipeline/coordinator.rb +176 -0
- data/lib/good_pipeline/cycle_detector.rb +36 -0
- data/lib/good_pipeline/engine.rb +23 -0
- data/lib/good_pipeline/errors.rb +11 -0
- data/lib/good_pipeline/failure_metadata.rb +29 -0
- data/lib/good_pipeline/graph_validator.rb +71 -0
- data/lib/good_pipeline/pipeline.rb +122 -0
- data/lib/good_pipeline/runner.rb +63 -0
- data/lib/good_pipeline/step_definition.rb +18 -0
- data/lib/good_pipeline/version.rb +5 -0
- data/lib/good_pipeline.rb +45 -0
- data/mise.toml +10 -0
- data/sig/good_pipeline.rbs +4 -0
- metadata +204 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9f30546b22291c0898027eb5a9458771ab943c424c20312f3ea3a03b954e9f30
|
|
4
|
+
data.tar.gz: 965deb9b03bfca479696dbf1c6baa980e57c332c4f75752912abb5027d31b44a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8faa2b2c58f1a6dce5a5b10b3498a24f70d36516b4a5d949afa594297eae4f28b10806f4484dad65645a0c7807f9daea0277d36ff127452ccfd845b610978749
|
|
7
|
+
data.tar.gz: 250813f051c7a5566666e11f73e260251b10b3a1c6957d7da52c2a4b79faa8d38bbf720741dce429ec09fa31a69cf50d23b5eb87d75d6c80e35bbb75643ae0ea
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-20
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Pipeline DSL** — `GoodPipeline::Pipeline` base class with `configure` method and `run` as the sole DSL verb
|
|
8
|
+
- **DAG validation** — cycle detection (three-color DFS), duplicate keys, unknown references, self-dependencies, and empty pipeline checks — all at instantiation time before any database writes
|
|
9
|
+
- **Three failure strategies** — `:halt` (default), `:continue`, and `:ignore` at pipeline level, with per-step `on_failure:` override
|
|
10
|
+
- **Coordinator** — sole owner of all `coordination_status` transitions with explicit transaction boundaries, `FOR UPDATE SKIP LOCKED` row locking, and `good_job_id` null guard to prevent double-enqueue
|
|
11
|
+
- **Atomic enqueue** — step status transition and GoodJob record insertion in a single Postgres transaction
|
|
12
|
+
- **Pipeline chaining** — `.then()` API for serial chains, fan-out, fan-in, and `GoodPipeline.run()` for parallel start
|
|
13
|
+
- **Lifecycle callbacks** — `on_complete`, `on_success`, `on_failure` with asynchronous dispatch via `PipelineCallbackJob` and exactly-once guarantee via `callbacks_dispatched_at` guard
|
|
14
|
+
- **Web dashboard** — mountable Rails engine with pipeline executions list (status tabs, type filter, keyset pagination), pipeline details page (steps table, Mermaid DAG visualization, chain links), and pipeline definitions catalog
|
|
15
|
+
- **Automatic cleanup** — subscribes to GoodJob's `cleanup_preserved_jobs` notification to delete terminal pipelines using the same retention period
|
|
16
|
+
- **Install generator** — `rails generate good_pipeline:install` creates migration for four tables (`good_pipeline_pipelines`, `good_pipeline_steps`, `good_pipeline_dependencies`, `good_pipeline_chains`)
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MilkStraw AI
|
|
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,217 @@
|
|
|
1
|
+
# GoodPipeline
|
|
2
|
+
|
|
3
|
+
DAG-based job pipeline orchestration for Rails, built on [GoodJob](https://github.com/bensheldon/good_job).
|
|
4
|
+
|
|
5
|
+
Define multi-step workflows as directed acyclic graphs, where each step is a GoodJob job. GoodPipeline handles dependency resolution, parallel execution, failure strategies, pipeline chaining, lifecycle callbacks, and provides a built-in web dashboard.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Ruby >= 3.2
|
|
10
|
+
- Rails >= 7.1
|
|
11
|
+
- PostgreSQL
|
|
12
|
+
- GoodJob >= 3.10 with `preserve_job_records = true`
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Add to your Gemfile:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem "good_pipeline"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Then install the migrations:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bin/rails generate good_pipeline:install
|
|
26
|
+
bin/rails db:migrate
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
GoodPipeline requires GoodJob to preserve job records. Add this to your GoodJob configuration:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
# config/initializers/good_job.rb
|
|
33
|
+
GoodJob.preserve_job_records = true
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
GoodPipeline will raise `GoodPipeline::ConfigurationError` at boot if this is not set.
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Defining a pipeline
|
|
41
|
+
|
|
42
|
+
Subclass `GoodPipeline::Pipeline` and implement `configure`. Use `run` to declare steps and `after:` to express dependencies:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
class VideoProcessingPipeline < GoodPipeline::Pipeline
|
|
46
|
+
description "Downloads, transcodes and publishes a video"
|
|
47
|
+
failure_strategy :halt
|
|
48
|
+
|
|
49
|
+
on_complete :notify
|
|
50
|
+
on_success :celebrate
|
|
51
|
+
on_failure :alert
|
|
52
|
+
|
|
53
|
+
def configure(video_id:)
|
|
54
|
+
run :download, DownloadJob, with: { video_id: video_id }
|
|
55
|
+
run :transcode, TranscodeJob, after: :download
|
|
56
|
+
run :thumbnail, ThumbnailJob, after: :download
|
|
57
|
+
run :publish, PublishJob, after: %i[transcode thumbnail]
|
|
58
|
+
run :cleanup, CleanupJob, after: :publish
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def notify = Rails.logger.info("Pipeline complete")
|
|
64
|
+
def celebrate = Rails.logger.info("All steps succeeded!")
|
|
65
|
+
def alert = Rails.logger.warn("Pipeline had failures")
|
|
66
|
+
end
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This produces the following DAG:
|
|
70
|
+
|
|
71
|
+
```mermaid
|
|
72
|
+
graph TD
|
|
73
|
+
download --> transcode
|
|
74
|
+
download --> thumbnail
|
|
75
|
+
transcode --> publish
|
|
76
|
+
thumbnail --> publish
|
|
77
|
+
publish --> cleanup
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Running a pipeline
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
VideoProcessingPipeline.run(video_id: 123)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Step options
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
run :step_key, JobClass,
|
|
90
|
+
with: { key: "value" }, # keyword args passed to the job
|
|
91
|
+
after: :other_step, # dependency (symbol or array of symbols)
|
|
92
|
+
on_failure: :ignore, # step-level failure strategy override
|
|
93
|
+
queue: :media, # optional queue override
|
|
94
|
+
priority: 10 # optional priority override
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Failure strategies
|
|
98
|
+
|
|
99
|
+
Set at the pipeline level with `failure_strategy`:
|
|
100
|
+
|
|
101
|
+
| Strategy | Behaviour |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `:halt` (default) | Stop all pending steps when any step fails |
|
|
104
|
+
| `:continue` | Let independent branches continue; skip only blocked downstream steps |
|
|
105
|
+
| `:ignore` | Treat failures as successes for dependency resolution |
|
|
106
|
+
|
|
107
|
+
Per-step overrides via `on_failure:` in `run` apply to that step's outgoing edges only.
|
|
108
|
+
|
|
109
|
+
### Pipeline chaining
|
|
110
|
+
|
|
111
|
+
Chain pipelines together with `.then()`:
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
# Serial chain
|
|
115
|
+
VideoProcessingPipeline
|
|
116
|
+
.run(video_id: 123)
|
|
117
|
+
.then(NotificationPipeline, with: { video_id: 123 })
|
|
118
|
+
|
|
119
|
+
# Fan-out
|
|
120
|
+
VideoProcessingPipeline
|
|
121
|
+
.run(video_id: 123)
|
|
122
|
+
.then(
|
|
123
|
+
[NotificationPipeline, with: { video_id: 123 }],
|
|
124
|
+
[AnalyticsPipeline, with: { video_id: 123 }]
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Parallel start with fan-in
|
|
128
|
+
GoodPipeline.run(
|
|
129
|
+
[VideoProcessingPipeline, with: { video_id: 123 }],
|
|
130
|
+
[AudioProcessingPipeline, with: { audio_id: 456 }]
|
|
131
|
+
).then(MergeMediaPipeline, with: { video_id: 123, audio_id: 456 })
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
If an upstream pipeline fails or halts, downstream pipelines are automatically skipped.
|
|
135
|
+
|
|
136
|
+
### Monitoring
|
|
137
|
+
|
|
138
|
+
```ruby
|
|
139
|
+
pipeline = VideoProcessingPipeline.run(video_id: 123)
|
|
140
|
+
|
|
141
|
+
pipeline.status # => "running"
|
|
142
|
+
pipeline.terminal? # => false
|
|
143
|
+
pipeline.steps # => all step records
|
|
144
|
+
pipeline.params # => { "video_id" => 123 }
|
|
145
|
+
|
|
146
|
+
# Query across pipelines
|
|
147
|
+
GoodPipeline::PipelineRecord.where(status: "failed")
|
|
148
|
+
GoodPipeline::PipelineRecord.where(type: "VideoProcessingPipeline")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Lifecycle callbacks
|
|
152
|
+
|
|
153
|
+
```ruby
|
|
154
|
+
class MyPipeline < GoodPipeline::Pipeline
|
|
155
|
+
on_complete :always_runs # any terminal state
|
|
156
|
+
on_success :only_success # pipeline succeeded
|
|
157
|
+
on_failure :only_failure # pipeline failed or halted
|
|
158
|
+
end
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Callbacks are dispatched asynchronously via a separate GoodJob job. They never block the coordinator or affect pipeline state.
|
|
162
|
+
|
|
163
|
+
## Dashboard
|
|
164
|
+
|
|
165
|
+
GoodPipeline includes a mountable web dashboard for inspecting pipeline executions:
|
|
166
|
+
|
|
167
|
+
```ruby
|
|
168
|
+
# config/routes.rb
|
|
169
|
+
mount GoodPipeline::Engine => "/good_pipeline"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The dashboard provides:
|
|
173
|
+
|
|
174
|
+
- Pipeline Executions: filterable list with status tabs and pipeline type dropdown
|
|
175
|
+
- Pipeline Details: steps table, DAG visualization, chain links, error info
|
|
176
|
+
- Pipeline Definitions: catalog of all pipeline types with their DAG structure
|
|
177
|
+
|
|
178
|
+
### Pipeline Executions
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
### Pipeline Details
|
|
183
|
+
|
|
184
|
+

|
|
185
|
+
|
|
186
|
+
### Pipeline Definitions
|
|
187
|
+
|
|
188
|
+

|
|
189
|
+
|
|
190
|
+
No build step required. Uses Pico CSS and Mermaid.js from CDN.
|
|
191
|
+
|
|
192
|
+
## Cleanup
|
|
193
|
+
|
|
194
|
+
GoodPipeline automatically cleans up old terminal pipelines when GoodJob runs its own cleanup cycle. No configuration needed, it uses GoodJob's retention period (default 14 days).
|
|
195
|
+
|
|
196
|
+
To configure the retention period, set GoodJob's option:
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
# config/application.rb
|
|
200
|
+
config.good_job.cleanup_preserved_jobs_before_seconds_ago = 30.days.to_i
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
bin/setup
|
|
207
|
+
mise docker:start # PostgreSQL
|
|
208
|
+
rake test
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/milkstrawai/good_pipeline.
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "minitest/test_task"
|
|
5
|
+
require "rubocop/rake_task"
|
|
6
|
+
|
|
7
|
+
Minitest::TestTask.create(:test_unit) do |task|
|
|
8
|
+
task.test_globs = ["test/**/*test*.rb"]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "Run integration tests"
|
|
12
|
+
task :test_integration do
|
|
13
|
+
sh "ruby -Idemo/test -e 'Dir[\"demo/test/**/*test*.rb\"].sort.each { |file| require File.expand_path(file) }'"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task test: %i[test_unit test_integration]
|
|
17
|
+
|
|
18
|
+
RuboCop::RakeTask.new
|
|
19
|
+
|
|
20
|
+
task default: %i[test rubocop]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GoodPipeline
|
|
4
|
+
class FrontendsController < ApplicationController
|
|
5
|
+
def static
|
|
6
|
+
file_name = "#{sanitized_id}.#{sanitized_format}"
|
|
7
|
+
file_path = assets_directory.join(file_name)
|
|
8
|
+
|
|
9
|
+
if file_path.exist?
|
|
10
|
+
expires_in 1.year, public: true
|
|
11
|
+
send_file file_path, disposition: :inline
|
|
12
|
+
else
|
|
13
|
+
head :not_found
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def sanitized_id
|
|
20
|
+
params[:id].to_s.gsub(/[^a-zA-Z0-9_-]/, "")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def sanitized_format
|
|
24
|
+
params[:format].to_s.gsub(/[^a-zA-Z0-9]/, "")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def assets_directory
|
|
28
|
+
GoodPipeline::Engine.root.join("app", "frontend", "good_pipeline")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GoodPipeline
|
|
4
|
+
class PipelinesController < ApplicationController
|
|
5
|
+
PAGE_SIZE = 25
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
@status = params[:status].presence
|
|
9
|
+
@pipeline_type = params[:pipeline_type].presence
|
|
10
|
+
@pipeline_types = PipelineRecord.distinct.pluck(:type).sort
|
|
11
|
+
counts_scope = @pipeline_type ? PipelineRecord.where(type: @pipeline_type) : PipelineRecord
|
|
12
|
+
@status_counts = counts_scope.group(:status).count
|
|
13
|
+
@total_count = @status_counts.values.sum
|
|
14
|
+
load_pipelines
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def definitions
|
|
18
|
+
pipeline_types = PipelineRecord.distinct.pluck(:type).sort
|
|
19
|
+
pipeline_ids = pipeline_types.filter_map do |type|
|
|
20
|
+
PipelineRecord.where(type: type).order(created_at: :desc).pick(:id)
|
|
21
|
+
end
|
|
22
|
+
@pipelines = PipelineRecord.includes(:steps, dependencies: %i[step depends_on_step])
|
|
23
|
+
.where(id: pipeline_ids)
|
|
24
|
+
.sort_by(&:type)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def show
|
|
28
|
+
scope = PipelineRecord.includes(
|
|
29
|
+
:upstream_pipelines, :downstream_pipelines, :steps,
|
|
30
|
+
dependencies: %i[step depends_on_step]
|
|
31
|
+
)
|
|
32
|
+
@pipeline = scope.find(params[:id])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def load_pipelines
|
|
38
|
+
scope = PipelineRecord.order(created_at: :desc, id: :desc)
|
|
39
|
+
scope = scope.where(status: @status) if @status
|
|
40
|
+
scope = scope.where(type: @pipeline_type) if @pipeline_type
|
|
41
|
+
scope = apply_keyset_pagination(scope)
|
|
42
|
+
records = scope.limit(PAGE_SIZE + 1).to_a
|
|
43
|
+
@has_next_page = records.size > PAGE_SIZE
|
|
44
|
+
@pipelines = records.first(PAGE_SIZE)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def apply_keyset_pagination(scope)
|
|
48
|
+
return scope unless params[:after_created_at].present? && params[:after_id].present?
|
|
49
|
+
|
|
50
|
+
scope.where(
|
|
51
|
+
"(created_at, id) < (?, ?)",
|
|
52
|
+
params[:after_created_at],
|
|
53
|
+
params[:after_id]
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|