Skip to content

BackgroundJob API is unusable #4818

@BernhardPosselt

Description

@BernhardPosselt

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions