Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task triggers (ie deploy) #59

Open
kbond opened this issue Apr 13, 2022 · 0 comments
Open

Task triggers (ie deploy) #59

kbond opened this issue Apr 13, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@kbond
Copy link
Member

kbond commented Apr 13, 2022

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
    {
        // ...
    }
}
@kbond kbond added the enhancement New feature or request label Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant