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

BackgroundJob API is unusable #4818

Closed
BernhardPosselt opened this issue May 11, 2017 · 2 comments
Closed

BackgroundJob API is unusable #4818

BernhardPosselt opened this issue May 11, 2017 · 2 comments
Labels
enhancement stale Ticket or PR with no recent activity technical debt
Milestone

Comments

@BernhardPosselt
Copy link
Member

The public background job API is afaik used by specifying this in your info.xml

<background-jobs>
    <job>OCA\News\Cron\Updater</job>
</background-jobs>

Then the specified class has to implement this interface https://github.com/nextcloud/server/blob/master/lib/public/BackgroundJob/IJob.php

As you may have noticed the public interface is absolutely unusable, that's why there is https://github.com/nextcloud/server/blob/master/lib/private/BackgroundJob/Job.php

Anyone who wants to implement something using the cronjob API however has to duplicate your code because the class lives in the private namespace. Would it be possible to give us mortal app devs access to a saner interface which works with DI :D?

interface IBackgroundJob {
    function run();
}

That can be used like this?

class Updater implements OCP\BackgroundJob\IBackgroundJob {
    public function __construct(UpdateService $updater) {
        $this->updater = $updater;
    }

    public function run() {
        $this->updater->updateFeeds();
    }
}

@LukasReschke @MorrisJobke @ChristophWurst

@nickvergessen
Copy link
Member

The current implementation has DI and it works quite nice.

As for cleaner interface, feel free to move the existing abstract jobs to the public api and thats it?

@BernhardPosselt
Copy link
Member Author

BernhardPosselt commented May 12, 2017

Should be fine, why not simply create:

namespace OCP\BackgroundJob;

abstract class BackgroundJob extends \OC\BackgroundJob {}

Interfaces can be changed later then (if needed at all, it's probably too late to clean up this mess anyways)

Can someone take care of this small change? My PHP still segfaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement stale Ticket or PR with no recent activity technical debt
Projects
None yet
Development

No branches or pull requests

4 participants