{"id":13879446,"url":"https://github.com/trailblazer/trailblazer-activity","last_synced_at":"2025-04-06T22:07:42.957Z","repository":{"id":18354520,"uuid":"83436411","full_name":"trailblazer/trailblazer-activity","owner":"trailblazer","description":"Model business workflows and run them.","archived":false,"fork":false,"pushed_at":"2024-11-13T10:12:26.000Z","size":1306,"stargazers_count":70,"open_issues_count":6,"forks_count":16,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-30T20:12:15.000Z","etag":null,"topics":["bpmn","flowchart"],"latest_commit_sha":null,"homepage":"https://trailblazer.to/2.1/docs/activity.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trailblazer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-28T13:34:48.000Z","updated_at":"2024-11-13T10:12:29.000Z","dependencies_parsed_at":"2024-11-06T13:41:54.842Z","dependency_job_id":"37f02fd9-e98a-475e-839b-fa73824de77a","html_url":"https://github.com/trailblazer/trailblazer-activity","commit_stats":{"total_commits":1132,"total_committers":12,"mean_commits":94.33333333333333,"dds":0.03710247349823326,"last_synced_commit":"5411b1b01d534bff73e115a2370dbd9cd32f801a"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailblazer%2Ftrailblazer-activity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailblazer%2Ftrailblazer-activity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailblazer%2Ftrailblazer-activity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailblazer%2Ftrailblazer-activity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trailblazer","download_url":"https://codeload.github.com/trailblazer/trailblazer-activity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bpmn","flowchart"],"created_at":"2024-08-06T08:02:21.336Z","updated_at":"2025-04-06T22:07:42.940Z","avatar_url":"https://github.com/trailblazer.png","language":"Ruby","funding_links":[],"categories":["Ruby","Building"],"sub_categories":["Workflows"],"readme":"# Activity\n\nImplements Intermediate, Implementation and compiler\n\nThe `activity` gem implements the runtime logic to invoke a new abstraction called \"activities\". Ideally, activities are defined using the [`dsl-linear` DSL gem](https://github.com/trailblazer/trailblazer-activity-dsl-linear).\n\nA process is a set of arbitrary pieces of logic you define, chained together and put into a meaningful context by an activity. Activity lets you focus on the implementation of steps while Trailblazer takes care of the control flow.\n\nPlease find the [full documentation on the Trailblazer website](https://trailblazer.to/2.1/docs/activity.html).\n\n## Example\n\nIn conjunction with [`dsl-linear`](https://github.com/trailblazer/trailblazer-activity-dsl-linear), the `activity` gem provides three default patterns to model processes: `Path`, `Railway` and `FastTrack`. Here's an example of what a railway activity could look like, along with some more complex connections (you can read more about Railway strategy in the [docs](https://trailblazer.to/2.1/docs/activity.html#activity-strategy-railway)).\n\n```ruby\nrequire \"trailblazer-activity\"\nrequire \"trailblazer-activity-dsl-linear\"\n\nclass Memo::Update \u003c Trailblazer::Activity::Railway\n  # here goes your business logic\n  #\n  def find_model(ctx, id:, **)\n    ctx[:model] = Memo.find_by(id: id)\n  end\n\n  def validate(ctx, params:, **)\n    return true if params[:body].is_a?(String) \u0026\u0026 params[:body].size \u003e 10\n    ctx[:errors] = \"body not long enough\"\n    false\n  end\n\n  def save(ctx, model:, params:, **)\n    model.update_attributes(params)\n  end\n\n  def log_error(ctx, params:, **)\n    ctx[:log] = \"Some idiot wrote #{params.inspect}\"\n  end\n\n  # here comes the DSL describing the layout of the activity\n  #\n  step :find_model\n  step :validate, Output(:failure) =\u003e End(:validation_error)\n  step :save\n  fail :log_error\nend\n```\n\nVisually, this would translate to the following circuit.\n\n\u003cimg src=\"http://trailblazer.to/images/2.1/activity-readme-example.png\"\u003e\n\nYou can run the activity by invoking its `call` method.\n\n```ruby\nctx = { id: 1, params: { body: \"Awesome!\" } }\n\nsignal, (ctx, *) = Update.( [ctx, {}] )\n\npp ctx #=\u003e\n{:id=\u003e1,\n :params=\u003e{:body=\u003e\"Awesome!\"},\n :model=\u003e#\u003cMemo body=nil\u003e,\n :errors=\u003e\"body not long enough\"}\n\npp signal #=\u003e #\u003cstruct Trailblazer::Activity::End semantic=:validation_error\u003e\n```\n\nWith Activity, modeling business processes turns out to be ridiculously simple: You define what should happen and when, and Trailblazer makes sure _that_ it happens.\n\n## Features\n\n* Activities can model any process with arbitrary flow and connections.\n* Nesting and compositions are allowed and encouraged (via Trailblazer's [`dsl-linear`](https://github.com/trailblazer/trailblazer-activity-dsl-linear) gem).\n* Different step interfaces, manual processing of DSL options, etc is all possible.\n* Steps can be any kind of callable objects.\n* Tracing! (via Trailblazer's [`developer`](https://github.com/trailblazer/trailblazer-developer) gem)\n\n## Operation\n\nTrailblazer's [`Operation`](https://trailblazer.to/2.1/docs/operation.html#operation-overview) internally uses an activity to model the processes.\n\n## Workflow\nActivities can be formed into bigger compounds and using workflow, you can build long-running processes such as a moderated blog post or a parcel delivery. Also, you don't have to use the DSL but can use the [`editor`](https://trailblazer.to/2.1/docs/pro.html#pro-editor)instead(cool for more complex, long-running flows). Here comes a sample screenshot.\n\n\u003cimg src=\"http://trailblazer.to/2.1/dist/img/flow.png\"\u003e\n\n## License\n\n© Copyright 2018, Trailblazer GmbH\n\nLicensed under the LGPLv3 license. We also offer a commercial-friendly [license](https://trailblazer.to/2.1/docs/pro.html#pro-license).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailblazer%2Ftrailblazer-activity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrailblazer%2Ftrailblazer-activity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailblazer%2Ftrailblazer-activity/lists"}