ostark / craft-relax

Less database I/O - faster Craft sites
MIT License
11 stars 2 forks source link

Ability to change queue ttr (time to reserve) #3

Closed KarlBishop closed 2 years ago

KarlBishop commented 2 years ago

We have occasional long-running queue jobs, like Blitz Cache Warmer and FeedMe imports, that need a very large ttr (time to reserve).

Is there a way I can increase ttr when using this plugin?

I have a custom value set in app.php ('components' => [ 'queue' => [ 'ttr' => 1800) but new jobs are now created with ttr of 300.

Great work anyway! If it's not possible at the moment then I'd be interested to know what you think of this as a feature request.

ostark commented 2 years ago

I'll look into this.

ostark commented 2 years ago

This should do the trick:

// config/app.php
return [
  'components' => [],
  'bootstrap' => [
    function () {
      \yii\base\Event::on(
        \yii\queue\Queue::class, 
        \yii\queue\Queue::EVENT_BEFORE_PUSH, 
          function (\yii\queue\PushEvent $event) {
              $event->ttr = 1234;
          }
      );
    }
  ]
];
KarlBishop commented 2 years ago

Fantastic - thanks!