Skip to content

Task triggers (ie deploy) #59

@kbond

Description

@kbond

Ability to add tasks to a "trigger group" like deploy:

class AppScheduleBuilder implements ScheduleBuilder
{
    public function buildSchedule(Schedule $schedule): void
    {
        $schedule->addCommand('app:warm-cache')
            ->trigger('deploy')
            ->unscheduled() // disables task from bring run except when "triggered"
        ;

        $schedule->addCommand('app:health-check')
            ->hourly() // also runs hourly
            ->trigger('deploy', priority: 10) // would run before the above task
        ;

        // ...
    }
}

Run the trigger (ie in a post deployment script):

bin/console schedule:trigger deploy

Combined with #58:

#[Schedule('@daily', trigger: 'deploy')]
class MyService
{
    public function __invoke()
    {
        // ...
    }
}

#[Schedule('@weekly', trigger: 'deploy')]
class MyCommand extends Command
{
    public function execute(InputInterface $input, OutputInterface $output): int
    {
        // ...
    }
}

A dedicated Trigger attribute could be added to make unscheduled invokable service/console command tasks:

#[Trigger('deploy')]
class MyService
{
    public function __invoke()
    {
        // ...
    }
}

#[Trigger('deploy')]
class MyCommand extends Command
{
    public function execute(InputInterface $input, OutputInterface $output): int
    {
        // ...
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions