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

Queue support #1773

Merged
merged 24 commits into from
Aug 19, 2019
Merged

Queue support #1773

merged 24 commits into from
Aug 19, 2019

Conversation

luceos
Copy link
Member

@luceos luceos commented Apr 15, 2019

Relates to #978

TO DO

  • Rewrite mail handling, possibly using Mailables
  • Document the driver configuration
  • Create a test to check the sync driver works.

Changes proposed in this pull request:

This PR adds queue ability, it sets the driver to sync by default. It will also enable the commands if the driver is something else than the sync or null driver.

Reviewers should focus on:

Does this implementation comply to our conventions and do you foresee issues in extensibility.

Confirmed

  • Backend changes: tests are green (run php vendor/bin/phpunit).

Required changes:

  • Related documentation PR: (Remove if irrelevant)
  • Related core extension PRs: (Remove if irrelevant)

@luceos
Copy link
Member Author

luceos commented Apr 15, 2019

@flarum/core I have been considering adding a Configuring event here as well, to immediately override the default queue. Instead of needing to work with a afterResolving callback. What do you think?

@luceos luceos marked this pull request as ready for review April 15, 2019 12:26
@luceos luceos requested a review from franzliedke April 15, 2019 12:26
@tobyzerner
Copy link
Contributor

Looks good, I think afterResolving is fine since its use should only be internal anyway (the public API should be an extender).

@franzliedke
Copy link
Contributor

I agree with @tobscure, the event shouldn't be necessary.

});

$this->app->singleton(Factory::class, function ($app) {
$manager = new QueueManager($app);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really benefit from the manager here? I don't think we need to support multiple queue backends, and using the manager just means that we'll have to translate extension configuration (e.g. settings in a GUI) into Laravel config and let the manager turn that into a connector instance. Why not turn our settings into a driver directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, didn't even consider that. We don't even need the configuration, any listener that binds into the resolving of this binding can change what queue driver is being used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so simplifying the binding doesn't work, because the Mailer instance expects a Factory, not an implementation..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Validator too. I've reverted my latest commits. Please review again @flarum/core .

tobyzerner
tobyzerner previously approved these changes Apr 16, 2019
@luceos luceos requested a review from franzliedke May 8, 2019 13:28
@luceos
Copy link
Member Author

luceos commented May 20, 2019

@franzliedke is this something we can take along for beta 9? 🥷

Never mind, testing this for @Bokt and the commands aren't showing yet.

@luceos
Copy link
Member Author

luceos commented May 20, 2019

This is starting to become very ugly. The queue worker needs a cache and does so by resolving cache from ioc and then calling a method driver(). We don't use the cache manager.

    protected function runWorker($connection, $queue)
    {
        $this->worker->setCache($this->laravel['cache']->driver());

        return $this->worker->{$this->option('once') ? 'runNextJob' : 'daemon'}(
            $connection, $queue, $this->gatherWorkerOptions()
        );
    }

I'll try to get an implementation done and then review how to improve all this.

@luceos
Copy link
Member Author

luceos commented Jul 8, 2019

@franzliedke subtle request to give this PR a review 🤞

@franzliedke
Copy link
Contributor

Oh wow, this part of Laravel is indeed a bit too highly coupled. Thankfully, change is on the horizon. As we can't wait for that, I will experiment with alternatives in the meantime.

The `Worker` class doesn't really need it. It only needs a
connection factory and one additional method (for detecting
whether the app is in maintenance mode), but unfortunately
type-hints the `QueueManager` class.

Laravel 6.0 will improve this, so let's hack our way around
it for now by building a minimal subclass of `QueueManager`
that only supports those two methods.

Once we upgrade to Laravel 6.0, the hack can simply be removed.
Again, Laravel wants the whole manager even though it only needs a
repository instance. Let's build a minimal workaround again until
this situation is resolved. (I submitted a PR to Laravel.)
That concept doesn't apply here - extensions will have to take
care of running migrations if needed.
[ci skip] [skip ci]
@franzliedke
Copy link
Contributor

I pushed a few commits that let us avoid the managers. Let me know what you think.

@luceos luceos merged commit a045f8b into master Aug 19, 2019
@luceos luceos deleted the dk/978-queue-implementation branch August 19, 2019 19:44
franzliedke added a commit that referenced this pull request Aug 22, 2019
luceos added a commit that referenced this pull request Feb 4, 2020
Implementation of clean queue handling, by default sync is used
luceos pushed a commit that referenced this pull request Feb 4, 2020
wzdiyb pushed a commit to wzdiyb/core that referenced this pull request Feb 16, 2020
Implementation of clean queue handling, by default sync is used
wzdiyb pushed a commit to wzdiyb/core that referenced this pull request Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants