Venture allows you to create and manage complex, async workflows in your Laravel apps.

Overview

Venture is a package to help you build and manage complex workflows of interdependent jobs using Laravel's queueing system.

Installation

Note: Venture needs PHP 8 and Laravel 8

composer require sassnowski/venture

Make sure to read the documentation for the full installation instructions.

Documentation

You can find the full documentation here.

Credits

Special thanks to @Caneco for the logo.

License

MIT

Comments
  • feat: save dependantJobs as array of stepIds rather than job instances

    feat: save dependantJobs as array of stepIds rather than job instances

    I recently started having concerns about the payload size when saving dependantJobs with full job payloads and today I got my first exception for workflow_jobs.job column being too small. Average size of the job column for my project while testing is almost 20kb, with jobs regularly creeping up towards 40-50kb and this is just for the small workflows/jobs in the project. This PR reduces the size of the job column by 85% on average for me, but upwards of 95% on my current test data.

    What are your thoughts on this?

    enhancement 
    opened by connors511 12
  • Duplicate jobs support

    Duplicate jobs support

    I took the liberty of trying to solve the limitation of duplicate jobs, as I need it for a project.

    I'm guessing there's a few areas in the code you might want to have changed or adjusted, so consider this more of a jumping off point for discussion :)

    This PR changes the following;

    • Instead of relying on jobClassName, switch to using stepId in the graph
    • Keep a classMap for lookup, instead of having to inspect the graph constantly
    • Add getDependenciesAsJobs for similar functionality to getDependantJobs but backwards compatible by keeping current method
    • Loosen visibility of resolveDependencies so WorkflowDefinition can use it
    • Added hasWorkflow method to easier test if workflows were merged instead of having to assert all of the individual jobs were added
    • Added getWorkflow method to easier make assertions on added workflows
    opened by connors511 12
  • Cant get nested Workflows to work?

    Cant get nested Workflows to work?

    I wanted to test out the nested workflows, so I did the following. Its a typical scenario of document signing.

    I have a bunch of dummy jobs that does nothing else than write a line in the log. just to see that it works.

    return Workflow::define('Sign a document')
        ->addJob(new PrepareDocumentForSigning($this->document))
        ->addWorkflow(new FirstOrderSigning($this->document), [
            PrepareDocumentForSigning::class,
        ])
        ->addWorkflow(new SecondOrderSigning($this->document), [
            FirstOrderSigning::class,
        ])
        ->addJob(new ExecuteDocument($this->document), [
            SecondOrderSigning::class,
        ])
        ->addJob(new SendExecutedDocument($this->document), [
            ExecuteDocument::class,
        ])
        ->catch(function (\Sassnowski\Venture\Models\Workflow $workflow, $job, Throwable $e) {
            info("Workflow cancelled " .  $e);
            $workflow->cancel();
        });
    

    FirstOrderSigning and SecondOrderSigning are identical and its content is:

    class FirstOrderSigning extends AbstractWorkflow
    {
        private Document $document;
    
        public function __construct(Document $document)
        {
            $this->document = $document;
        }
    
        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Sign a document')
                ->addJob(new SendSigningEmailInvite($this->document))
                ->addJob(new CaptureSignature($this->document), [
                    SendSigningEmailInvite::class,
                ]);
        }
    }
    

    I run

    SignDocumentWorkflow::start($document);
    

    but Horizon outputs only 1 job executed: (the one before the nested workflow)

    image

    However, if I remove those workflows and only use addJobs - then add 3 jobs get executed.

    return Workflow::define('Sign a document')
        ->addJob(new PrepareDocumentForSigning($this->document))
        ->addJob(new ExecuteDocument($this->document), [
            PrepareDocumentForSigning::class,
        ])
        ->addJob(new SendExecutedDocument($this->document), [
            ExecuteDocument::class,
        ])
        ->catch(function (\Sassnowski\Venture\Models\Workflow $workflow, $job, Throwable $e) {
            info("Workflow cancelled " .  $e);
            $workflow->cancel();
        });
    

    image

    What am I missing here?

    bug 
    opened by viezel 11
  • 4.0

    4.0

    The development of version 4.0 happens in the 4.x branch of this repository.

    Todo

    • [x] Implement Plugin System
    • [x] Replace vimeo/psalm with nunomaduro/larastan
    • [x] Define WorkflowStepInterface for workflow steps
    • [x] Add gated jobs (see #32 for reference)
    • [x] Add closure-based jobs (see #24) (968c26354d638fa5a8b3e7842a822344a803df67)
    • [x] Add testing helpers to run the then and catch callbacks of a workflow (42231332e4d0504f4c01cfd14980750ab39550b8)
    • [x] Add option to run all jobs of a workflow on a specific connection (804193ec60352110cd783e6a18897c0523376832)
    • [x] Add plugin to make workflows entity aware
    • [x] Add to workflow definition of existing workflow instance
    • [x] Write migration guide
      • [x] Migrating the database
      • [x] Minimum Laravel Version
      • [x] Steps should use WorkflowStepInterface
      • [x] Replace Workflow::define(...) with $this->define(...)
    • [x] Update documentation
      • [x] Update all examples to the new API
      • [x] Writing Plugins
      • [x] Optional EntityAwareWorkflows plugin
      • [x] Testing the then and catch callbacks of a workflow
      • [x] Define queue connection when starting a workflow
      • [x] Asserting that a workflow was started on a specific connection
      • [x] Adding jobs to an existing workflow instance
      • [x] Adding conditional jobs
      • [x] Depending on conditional jobs
      • [x] The callback passed to assertStarted now takes the job's queue connection as a second parameter
      • [x] Adding a closure to a workflow
      • [x] Gated jobs
      • [x] Staring a workflow synchronously
      • [x] Defining the queue connection for all jobs of a workflow
      • [x] Defining the queue for all jobs of a workflow
      • [x] Update section about testing workflows to use WorkflowTester
      • [x] Update section about inspecting workflow models to use state
      • [x] Customizing model states

    BC Breaks

    This section is used to keep track of all BC breaks this version introduces. While I will try to keep them to a minimum and provide sensible migration paths, there are a few warts in the current implementation that require a BC break to really fix.

    Drop Laravel 8 support

    Starting with 4.0, Venture will require Laravel 9.

    Jobs need to implement WorkflowStepInterface

    ~Since we can't type hint against traits, we currently have to resort to the object type whenever we're dealing with workflow jobs. Version 4.0 adds a proper interface and extends the existing WorkflowStep trait so it automatically implements the interface.~

    ~Since it's necessary to add implements WorkflowStepInterface to all existing workflow job classes, this is a BC break. We should be able to automate this with some sort of artisan command, however (e.g. venture:migrate-jobs). We basically have to look for classes that use the WorkflowStep trait and perform some kind of string replace on the class declaration.~

    I found a way to make this backwards compatible for now. Instead, adding a job that doesn't implement the interface to a workflow will trigger a deprecation warning in version 4.

    Workflow::define requires the workflow instance as the first parameter

    Up until now, the Workflow facade's define method only took a $name parameter. In version 4, this method takes an instance of AbstractWorkflow as a parameter.

    - Workflow::define('My workflow');
    + Workflow::define($this, 'My workflow');
    

    This is so we can acces the actual workflow class inside plugins, instead of only dealing with the WorkflowDefinition class. This allows users to define extra properties/methods on their workflow classes which can then be used by various plugins.

    As a convenience, the AbstractWorkflow class now provides a define method which automatically passes the current workflow instance to the Workflow::define method.

    - Workflow::define('My workflow');
    + $this->define('My workflow');
    

    Again, this is something we should be able to automate since it should be a rather straight-forward string replace.

    Changes to WorkflowManagerInterface::startWorkflow signature

    The WorkflowManagerInterface::startWorkflow method now takes a second parameter $connection which specifies the connection to use for all jobs of the workflow. If $connection is null, it will use whatever default connection has been set on the job.

    This is a fairly low-impact change as a I think it's unlikely that people will implement their own workflow manager or extend the default one. It is still a breaking change, however.

    StepIdGenerator needs to account for WorkflowStepAdapter

    Jobs that don’t implement WorkflowStepInterface directly now get wrapped in a WorkflowStepAdapter class. This means that when implementing a custom StepIdGenerator, you now need to account for this class and potentially unwrap it before generating the id.

    opened by ksassnowski 10
  • Non queued jobs not being marked as finished

    Non queued jobs not being marked as finished

    Not sure if I am being stupid but none of the job/steps ever get marked as finished (no update to finished_at column). Is this done automatically? Do I need to do it manually or is anything required to be returned from the handle() method in the Jobs?

    The workflow runs fine and all the jobs do complete, they are just not being marked as finished.

    opened by notomato 10
  • [Postgresql] Serialization/Unserialization error while using non-public fields on jobs

    [Postgresql] Serialization/Unserialization error while using non-public fields on jobs

    Hi, I recently started using this package but stumbled upon an issue around non-public fields on jobs.

    If a job has a non-public field PHP \unserialize function places a \0\0 value in front of it. When this serialized string is transferred into DB and it is accepted as a null-terminated string and as expected half of it is missing. So when this package tries to unserialize the string, it does not work.

    Currently, I made them public to overcome the issue but another solution might be possible. I thought about SerializesModels but, trait usage can not be checked against. So don't really know about it.

    Currently, I don't have the repro but if requested I can whip something up.

    laravel/framework v8.83.4 ksassnowski/venture 3.5.0 php8.1 Postgres 12

    opened by abdullahcanakci 9
  • beforeConnecting hook for merging workflows

    beforeConnecting hook for merging workflows

    It's possible to conditionally add jobs and workflows in the definition method, however, I'd like to have all my jobs added and instead early return from them before they do any work. In order to do so I've added a $shouldSkip property to my jobs and workflows.

    It works fine for jobs, but I'm having a little difficulty when merging workflows.

    Consider this example;

    Workflow::define('My workflow')
        ->addJob(new MyJob())
        ->addJob((new MyOtherJob())->skip($myCondition), [
            MyJob::class,
        ])
        ->addWorkflow((new MyConditionalWorkflow())->skip($myCondition), [
            MyOtherJob::class,
        ]);
    

    MyOtherJob is all good, but MyConditionalWorkflow currently needs a defintion like;

    Workflow::define('My conditional workflow')
        ->addJob(
            (new MyNestedJob())->skip($this->shouldSkip)
        )
    

    This gets kinda cumbersome very quickly when you have a few jobs in the nested workflow.

    WorkflowDefinition::addWorkflow could be modified with the following hook;

            $definition = $workflow->definition();
    
            if (method_exists($workflow, 'beforeConnecting')) {
                $workflow->beforeConnecting($definition->jobs);
            }
    

    -- or just call it regardless, if a no-op method was added to AbstractWorkflow like beforeCreate currently is.

    What's your thoughts? Open to a PR with tests for this, or for another implementation?


    For reference, my skip is basically just the following and similar for Jobs

    abstract class AbstractWorkflow extends \Sassnowski\Venture\AbstractWorkflow
    {
        protected bool $shouldSkip = false;
    
        public function skip(bool $shouldSkip = true)
        {
            return tap($this, fn () => $this->shouldSkip = $shouldSkip);
        }
    }
    
    enhancement 
    opened by connors511 9
  • Nesting workflows

    Nesting workflows

    Venture looks super interesting and very suitable for an upcoming project of mine. Could be super sweet if you could nest workflows to increase reusability of common workflows.

    For instance, the following example;

    
    class EncodeWorkflow extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Encode Podcast')
                ->addJob(new EncodePodcast($this->podcast, 'mp3'))
                ->addJob(new EncodePodcast($this->podcast, 'wav'));
        }
    }
    
    class OptimizeWorkflow extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Optimize Podcast')
                ->addJob(new AnalyzePodcast($this->podcast))
                ->addJob(new OptimizePodcast($this->podcast), [AnalyzePodcast::class])
                ->addWorkflow((new EncodeWorkflow($this->podcast))->definition(), [OptimizePodcast::class]);
        }
    }
    
    class PublishWorkflow extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            return $publishWorkflow = Workflow::define('Publish Podcast')
                ->addJob(new ReleaseOnTransistorFM($this->podcast))
                ->addJob(new ReleaseOnApplePodcasts($this->podcast));
        }
    }
    
    
    $processWorkflow = Workflow::define('Release Podcast')
        ->addJob(new ProcessPodcast($this->podcast))
        ->addWorkflow((new OptimizeWorkflow($this->podcast))->definition(), [ProcessPodcast::class])
        ->addWorkflow((new PublishWorkflow($this->podcast))->definition(), [OptimizeWorkflow::class]);
    
    

    Have you considered something like this for the package? If so, do you already have an idea for such an implementation, or would you be open to a PR when I start on the project that would benefit from such a feature?

    opened by connors511 9
  • Add support for user task

    Add support for user task

    Sometimes workflows have users involved to perform an action before the workflow step is complete and the overall workflow can continue. An example would be a user that needs to review and approve a blog post before it gets published. It would be beneficial to see support for user tasks within this package.

    A user task can be completed in e.g. a controller and the application should be able to update a specific workflow step to complete or cancelled.

    I believe we would need:

    • Jobs that do not automatically completes when run - but instead is in progress
    • workflow API to complete a step
    enhancement 
    opened by viezel 8
  • Add `hasRan()` method for easily retrieving workflow

    Add `hasRan()` method for easily retrieving workflow "done" status

    Description

    This PR adds the ability to easily fetch the entire completion status of a workflow. One that may have processed and failed jobs, but is actually done processing.

    Purpose

    In a workflow, some jobs may pass and some may fail, leaving the finished_at and cancelled_at timestamps empty. This simple helper method allows me to check if the workflow is actually "done", and then perform further analysis afterwards.

    Let me know if you'd like more tests added. Thanks so much for this package and your time! ❤️

    opened by stevebauman 7
  • Replace `opis/closure` with `laravel/serializable-closure`

    Replace `opis/closure` with `laravel/serializable-closure`

    The current stable version of opis/closure is not yet compatible with PHP 8.1 and produces various deprecation warnings. While version 4 aims to fix this, it is still in beta. So in the meantime, we're switching to laravel/serializable-closure.

    opened by ksassnowski 6
  • Venture incompatible with Laravel Jobs side by side usage.

    Venture incompatible with Laravel Jobs side by side usage.

    I attempted to add the package and use it on one process, but I am now unable to run any of my other non-venture jobs.

    So I started commenting out the events in the venture provider, then ran my test for my regular jobs, which are Laravel Actions Job, and it passed. All stim from the JobProcessed event appears to be attempting to unserialize a base64, which fails because regular jobs do not have base64 as far as I know?

    Step 1: https://github.com/ksassnowski/venture/blob/40a5bb1367cd61d8ac9da203a7b8b67134043e4b/src/VentureServiceProvider.php#L51

    Step 2: https://github.com/ksassnowski/venture/blob/40a5bb1367cd61d8ac9da203a7b8b67134043e4b/src/WorkflowEventSubscriber.php#L96

    Step 3: https://github.com/ksassnowski/venture/blob/40a5bb1367cd61d8ac9da203a7b8b67134043e4b/src/UnserializeJobExtractor.php#L27

    Step 4: https://github.com/ksassnowski/venture/blob/40a5bb1367cd61d8ac9da203a7b8b67134043e4b/src/Serializer/Base64WorkflowSerializer.php#L38

    So seems to be incompatible with Laravel Jobs and it's venture all or nothing.

    needs more info 
    opened by dragonfire1119 6
  • Workflow State Aware Jobs

    Workflow State Aware Jobs

    Afternoon,

    I'm currently doing research for work around using the Venture package for one of our projects. Something I noticed and wanted to see if you were interested in as a future feature/enhancement is making workflow jobs aware of their parent workflows state. For example, say you use a workflow to model an email campaign where follow-up emails are sent. But if any point in time, the receiver replies, we don't want to send any of the remaining follow-up emails:

    <?php declare(strict_types=1);
    
    namespace App;
    
    use Sassnowski\Venture\AbstractWorkflow;
    use Sassnowski\Venture\WorkflowDefinition;
    
    class WorkflowTest extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            $this->define('Workflow Name')
                ->addJob(id: 'send-first-followup', (new SendFollowUp())->delay($this->settings->first_delay))
                ->addJob(id: 'send-second-followup', (new SendFollowUp())->delay($this->settings->second_delay))
                ->addJob(id: 'send-third-followup', (new SendFollowUp())->delay($this->settings->third_delay));
        }
    }
    

    At the moment, I think this is possible with some logic on the end users' side, doing something like this in the Job class

    <?php declare(strict_types=1);
    
    namespace App\Jobs;
    
    use Sassnowski\Venture\WorkflowableJob;
    use Sassnowski\Venture\WorkflowStep;
    
    class SendFollowup implements WorkflowableJob
    {
        use WorkflowStep;
    
        public function handle(): void
        {
            if ($this->workflow()->isCancelled() || $this->workflow()->isFinished()) {
                return;
            }
    
            // send email
        }
    }
    

    And then, in our business logic, when we receive an inbound email from the user (or another event like an unsubscribe), we can manually reference the workflow and change its state to canceled or finished.

    What are your thoughts on making WorkflowableJob's state aware so that little to no code is needed to make workflow jobs aware of their parent's state and not execute or dispatch jobs if the workflow has already finished?

    opened by hskrasek 0
  • Persistence abstraction

    Persistence abstraction

    Would you be open to the introduction of a repository to make the persistence of models abstract?

    I'm not thinking any massively crazy refactor, but basically just a repository that persists (and fetches) the eloquent models, instead of calling save() directly on the model like here

    My motivation for this is

    1. Be able to use an in memory repository in my current project during tests
    2. Have an easy way to hook into loading/saving the models for extra metadata
    enhancement 
    opened by connors511 2
Releases(4.0.1)
  • 4.0.1(Sep 22, 2022)

    What's Changed

    • [4.x] Fix manually failed jobs reporting processed by @stevebauman in https://github.com/ksassnowski/venture/pull/59

    Full Changelog: https://github.com/ksassnowski/venture/compare/4.0.0...4.0.1

    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Aug 30, 2022)

  • 4.0.0-RC7(Aug 15, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go inside https://github.com/ksassnowski/venture/issues/54.


    Changed

    • [v4.x] Set Workflow/WorkflowJob::getState() methods to protected by @stevebauman in https://github.com/ksassnowski/venture/pull/57
    • Fix bug where dependent jobs would not get set correctly on jobs from nested workflow
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC6(Aug 11, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go inside https://github.com/ksassnowski/venture/issues/54.


    Changed

    • Fixed incorrect path when publishing migrations #56
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC5(Aug 11, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go inside https://github.com/ksassnowski/venture/issues/54.


    Changed

    • Renamed WorkflowStepInterface to WorkflowableJob
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC4(Jul 28, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go inside https://github.com/ksassnowski/venture/issues/54.


    Changed

    • Removed opis/closure dependency
    • Added isPending method to WorkflowJob model
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC3(Jul 20, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go inside https://github.com/ksassnowski/venture/issues/54.


    Changed

    • Made run method of AbstractWorkflow public
    • Removed $name property from JobAdded event. The job name can be retrieved via $job->getName().
    • Fire JobFinished event after the finished job was processed
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC2(Jul 19, 2022)

    This is a release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/. Check out the upgrade guide to learn how to upgrade you application to Venture 4.

    All feedback and bug reports should go into #54.


    Changed

    • Made WorkflowTester class fluent so assertions can be chained
    • Unwrap WorkflowStepAdapter jobs before passing them to the callback of WorkflowTester::assertJobExists and WorkflowTester::assertJobMissing
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0-RC1(Jul 19, 2022)

    This is the first release candidate for Venture 4. The documentation is still in progress, but can be found at https://laravel-venture-v4.netlify.app/

    Source code(tar.gz)
    Source code(zip)
  • 3.7.0(Jul 9, 2022)

    What's Changed

    • Add method to configure definition conditionally by @ksassnowski in https://github.com/ksassnowski/venture/pull/53

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.5...3.7.0

    Source code(tar.gz)
    Source code(zip)
  • 3.6.5(May 17, 2022)

    What's Changed

    • Replace opis/closure with laravel/serializable-closure by @ksassnowski in https://github.com/ksassnowski/venture/pull/52

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.4...3.6.5

    Source code(tar.gz)
    Source code(zip)
  • 3.6.4(Apr 16, 2022)

    What's changed

    • Moved UnserializeException to correct namespace

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.3...3.6.4

    Source code(tar.gz)
    Source code(zip)
  • 3.6.3(Apr 16, 2022)

    What's Changed

    • Add php-cs-fixer GitHub action by @stevebauman in https://github.com/ksassnowski/venture/pull/50
    • Base64 encode serialized jobs when using Postgres by @ksassnowski in https://github.com/ksassnowski/venture/pull/51

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.2...3.6.3

    Source code(tar.gz)
    Source code(zip)
  • 3.6.2(Apr 11, 2022)

    What's Changed

    • Add markAsFinished() method for overridability and make markJobAsFinished() protected by @stevebauman in https://github.com/ksassnowski/venture/pull/47

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.1...3.6.2

    Source code(tar.gz)
    Source code(zip)
  • 3.6.1(Apr 10, 2022)

    What's Changed

    • Fix Venture non static methods by @stevebauman in https://github.com/ksassnowski/venture/pull/48

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.6.0...3.6.1

    Source code(tar.gz)
    Source code(zip)
  • 3.6.0(Apr 5, 2022)

    What's Changed

    • Add ability to use a custom Workflow and WorkflowJob model by @stevebauman in https://github.com/ksassnowski/venture/pull/44

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.5.0...3.6.0

    Source code(tar.gz)
    Source code(zip)
  • 3.5.0(Feb 1, 2022)

    What's Changed

    • Add support for Laravel 9 by @ksassnowski in https://github.com/ksassnowski/venture/pull/41

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.4.0...3.5.0

    Source code(tar.gz)
    Source code(zip)
  • 3.4.0(Nov 19, 2021)

    Added

    • Add hasRan() method to workflow to check if all jobs have at lease been attempted once (#37). Credits, @stevebauman.
    • Add JobExtractor interface to extract a workflow job instance from a Laravel queue job. This gets used by the WorkflowEventSubscriber class.
    Source code(tar.gz)
    Source code(zip)
  • 3.3.2(Nov 18, 2021)

    What's Changed

    • Fix bug with missing workflow step generator in config if already published by @stevebauman in https://github.com/ksassnowski/venture/pull/40

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.3.1...3.3.2

    Source code(tar.gz)
    Source code(zip)
  • 3.3.1(Nov 18, 2021)

    Changed

    • Clone job instance before serializing it when saving the workflow to the database. This could lead to hard to track down bugs since serialize mutates the object in place.

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.3.0...3.3.1

    Source code(tar.gz)
    Source code(zip)
  • 3.3.0(Nov 18, 2021)

    What's Changed

    • Add interface to abstract id generation for workflow steps by @ksassnowski in https://github.com/ksassnowski/venture/pull/39

    Full Changelog: https://github.com/ksassnowski/venture/compare/3.2.0...3.3.0

    Source code(tar.gz)
    Source code(zip)
  • 3.2.0(Nov 16, 2021)

  • 3.1.2(Nov 13, 2021)

    Changed

    • Added missing int cast to jobs_failed property of Workflow model (#36). Credits, @stevebauman.
    • Added vimeo/psalm dependency for static type checking during development.
    • Added various missing type hints to get psalm to pass at level 2.

    Fixed

    • Fixed bug where WorkflowDefinition::hasWorkflow() wasn't working properly when checking for the workflow's $dependencies, too.
    Source code(tar.gz)
    Source code(zip)
  • 3.1.1(May 13, 2021)

    Changed

    • Store step id instead of serialized instance for dependent jobs. This could cause an error in rare cases if the job payload was too big (#30). Credits, @connors511.
    Source code(tar.gz)
    Source code(zip)
  • 3.1.0(Apr 21, 2021)

  • 3.0.1(Apr 20, 2021)

  • 3.0.0-RC2(Mar 2, 2021)

    This release candidate mostly cleans up the code. The biggest "change" is that most private method inside the WorkflowDefinition and DependencyGraph are now marked as protected instead. This is to make it easier to extend these classes to override their behaviors if necessary (see the discussion in #14 for context).

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Mar 30, 2021)

    Added

    • Added support for adding multiple instances of the same job to a workflow. Check the documentation for more details. See #14 for the discussion on this feature. Special thanks to @conors511 for his help.

    Changed

    • Change required minimum PHP version to 8.

    Removed

    • Removed addJobWithDelay method from WorkflowDefinition. You should use addJob and provide the delay parameter instead. Since this version of Venture requires PHP 8, you can make use of named arguments to skip any default parameters you don't want to change.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-RC1(Feb 28, 2021)

    The main focus of this release is to allow workflows to contain multiple instances of the same job. There are a few breaking changes which are listed below. There will be a proper migration guide once version 3 gets released.

    Adding multiple instances of the same job

    When you want to add multiple instances of the same job to a workflow, you have to provide explicit ids for them as part of the addJob method call.

    public function definition(): WorkflowDefinition
    {
        return Workflow::define('Workflow name')
            ->addJob(new EncodePodcast($this->podcast, 'mp3'), id: 'encode_mp3', name: 'Encode Podcast as mp3')
            ->addJob(new EncodePodcast($this->podcast, 'wav'), id: 'encode_wav', name: 'Encode Podcast as wav')
            ->addJob(new TranslatePodcast($this->podcast), dependencies: ['encode_mp3', 'encode_wav']);
    }
    

    You don't have to provide an id if you use the same job instance only once inside a workflow. In these cases, the FQCN of the job will be used as the id.

    public function definition(): WorkflowDefinition
    {
        return Workflow::define('Workflow name')
            ->addJob(new EncodePodcast($this->podcast, 'mp3'), name: 'Encode Podcast as mp3')
            ->addJob(new TranslatePodcast($this->podcast), dependencies: [EncodePodcast::class]);
    }
    

    This also works if there are duplicate jobs in nested workflows.

    class NestedWorkflow extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Name')
                ->addJob(new TestJob1());
        }
    }
    
    class OuterWorkflow extends AbstractWorkflow
    {
        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Name')
                ->addJob(new TestJob1())
                ->addWorkflow(new NestedWorkflow(), dependencies: [TestJob1::class]);
        }
    }
    

    The TestJob1 dependency of the NestedWorkflow will be correctly scoped to the TestJob1 defined in OuterWorkflow. Internally, this works by prefixing all job ids in the nested workflow with the id of the nested workflow when calling addWorkflow.

    Adding multiple instances of the same job with providing explicit ids for them will result in a DuplicateJobException.

     return Workflow::define('Workflow name')
            ->addJob(new EncodePodcast($this->podcast, 'mp3'))
             // Will throw a DuplicateJobException because a job with the id `EncodePodcast::class` already exists.
            ->addJob(new EncodePodcast($this->podcast, 'wav'));
    

    This works exactly the same way for nesting multiple instance of the same workflow.

        public function definition(): WorkflowDefinition
        {
            return Workflow::define('Name')
                ->addJob(new TestJob1())
                ->addWorkflow(new NestedWorkflow(), dependencies: [TestJob1::class], id: 'nested_workflow_1')
                // Works because we provided different ids for the two workflows.
                ->addWorkflow(new NestedWorkflow(), dependencies: [TestJob1::class], id: 'nested_workflow_2');
        }
    

    Whenever you provide explicit ids for either jobs or nested workflows, you have to refer to these ids when using them as dependencies.

    $definition
        ->addJob(new TestJob1(), id: 'test_job')
        // Will blow up because there is no job with an id of `TestJob1::class`
        ->addJob(new TestJob2(), dependencies: [TestJob1::class])
        // This works
        ->addJob(new TestJob3(), dependencies: ['test_job']);
    

    Breaking Changes

    PHP 8 required

    This version of Venture requires PHP 8. This is because in order to provide a nice API, both internally as well externally, named arguments are heavily used.

    WorkflowDefinition::addJobWithDelay has been removed.

    This method has always been a hack around the fact that addJob takes so many nullable parameters. It really was just addJob with a different order of parameters. With named parameters this problem goes away entirely. If you want to add a job without any dependencies, you skip all parameters you don't care about and simply write:

    Workflow::define('Name')
        ->addJob(new TestJob(), delay: now()->addMinutes(5));
    

    hasJob, hasJobWithDependencies and hasJobWithDelay now require job id instead of instance

    Previously, you could pass either the FQCN of the job or an instance of the job to any of these function like so:

    // Use FQCN
    $definition->hasJob(TestJob::class);
    
    // Use job instance
    $job = new TestJob();
    $definition->hasJob($job);
    

    Internally, Venture would check if you provided an instance and call get_class on it. This no longer works. Now, you always need to provide the job id.

    $job1 = new TestJob1();
    
    $definition = Workflow::define('Test')
        ->addJob($job1, id: 'job_1')
        ->addJob(new TestJob2()) // When no id is provided, the FQCN of the class is used as the id.
    
    $definition->hasJob($job1); // Error: Expected type 'string' but got 'TestJob1'
    $definition->hasJob(TestJob1::class); // false, because an explicit id was provided above
    $definition->hasJob('job_1'); // true,
    $definition->hasJob(TestJob2::class); // true
    
    
    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Jan 20, 2021)

Owner
Kai Sassnowski
Hi I'm Kai. I live in Munich. I like D&D. I work for @wycomco. I built https://utgars-chronicles.app
Kai Sassnowski
Greyhole uses Samba to create a storage pool of all your available hard drives, and allows you to create redundant copies of the files you store.

Greyhole Greyhole is an application that uses Samba to create a storage pool of all your available hard drives (whatever their size, however they're c

Guillaume Boudreau 245 Dec 18, 2022
EBook-Apps - The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop.

⚡️ eBook Apps The eBook Apps is a web application that helps you browse ebooks from anywhere using your smartphone and laptop. ?? Getting Started To s

Ahmad Fauzy 32 Nov 14, 2022
Allows generate class files parse from json and map json to php object, including multi-level and complex objects;

nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You

zhixin 2 Sep 9, 2022
The Workflow Package add Drag & Drop Workflows to your Laravel Application.

Workflows add Drag & Drop automation's to your Laravel application. The Workflow Package adds Drag & Drop Workflows to your Laravel Application. A Wor

42coders 196 Dec 29, 2022
This repository aims to build a fairly complete CI/CD example using GitHub workflows and actions.

CI/CD example This repository aims to build a fairly complete CI/CD example using GitHub workflows and actions. Keep in mind that the toolset used in

Robin Ingelbrecht 4 Nov 1, 2022
Magento 2 Blog is an extension that allows you to manage your store and blog

Magento 2 Blog Extension by Magefan Magento 2 Blog is an extension that allows you to manage your store and blog from one place without having to rely

Magefan 243 Dec 21, 2022
PHP functions that help you validate structure of complex nested PHP arrays.

PHP functions that help you validate structure of complex nested PHP arrays.

cd rubin 7 May 22, 2022
Talkino allows you to integrate multi social messengers and contact into your website and enable your users to contact you using multi social messengers' accounts.

Talkino Welcome to our GitHub Repository Talkino is a click to chat plugin to show your agents’ multiple social messengers, phone and emails on the ch

Traxconn 2 Sep 21, 2022
Integrate reCAPTCHA using async HTTP/2, making your app fast with a few lines.

ReCaptcha Integrate reCAPTCHA using async HTTP/2, making your app fast with a few lines. use Illuminate\Support\Facades\Route; Route::post('login', f

Laragear 14 Dec 6, 2022
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.

Kirby 3 Many To Many Field This plugin allows you to create many-to-many relationships between pages in Kirby.

Jonas Holfeld 41 Nov 19, 2022
This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized objects in DynamoDB 🚀.

DynamoDB Storable This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized

Matthieu W. 2 Jun 19, 2022
A useful PocketMine-MP plugin that allows you to create crates in-game!

ComplexCrates A useful PocketMine-MP plugin that allows you to create crates in-game! Commands Main command: /crate Sub commands: create

Oğuzhan 8 Aug 26, 2021
Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values

Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values. Miniset

Jack Sleight 5 Jun 13, 2022
Use php-fpm as a simple built-in async queue

PHP-FPM Async Queue Use php-fpm as a simple built-in async queue. Based on interoperable queue interfaces Queue Interop. Usage composer makasim/php-fp

Max Kotliar 111 Nov 19, 2022
An async process dispatcher for Amp.

process This package provides an asynchronous process dispatcher that works on all major platforms (including Windows). As Windows pipes are file hand

AMPHP 204 Jan 8, 2023
Simple async lowlevel ICMP (ping) messaging library built on top of React PHP

clue/icmp-react Simple async lowlevel ICMP (ping) messaging library built on top of react Usage Once clue/icmp-react is installed, you can run any of

Christian Lück 13 Jun 10, 2022
Stupid async implementation using await-generator

libAsync Stupid async implementation using await-generator Usage libAsync::doAsync(Closure $executor); // <-- Returns a promise Example Fetch data fro

null 5 Jan 2, 2023
Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3+ that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI.

laravelpodcast | A Laravel podcast manager package - v0.0.8 Introduction Laravel Podcast Manager is a complete podcast manager package for Laravel 5.3

Jeremy Kenedy 22 Nov 4, 2022