mjphaynes / php-resque

php-resque is a Redis-backed PHP library for creating background jobs, placing them on multiple queues, and processing them later.
MIT License
222 stars 50 forks source link

add feature Plugin #82

Closed merlindorin closed 4 years ago

merlindorin commented 6 years ago

see #81

If this feature is interesting, I'll write the related doc.

usage :

class SamplePlugin implement PluginInterface {

    public function init() {
        // do init stuff
    }
}

$plugin = new SamplePlugin();

Worker::registerPlugin($plugin);
scones commented 6 years ago

Personally i'd prefer a folder "Interfaces", rather than a folder "Plugin", which would only contain that interface.

But that's a matter of taste. The source is good.

xelan commented 6 years ago

Thank you @iam-merlin for the PR and @scones for the discussion. I'm +1 for the Plugin namespace, as it might make sense to add some built-in plugins which can be used as required by library users.

xelan commented 6 years ago

Thank you very much, the proposed plugin handling looks great👍

Before merging, I will conduct a more in-depth review and maybe get a second opinion as well. Then I'll test the new feature, and afterwards merge it.

Best regards Andreas

merlindorin commented 6 years ago

@xelan any news? (just want to know if I add some docs) and sample

xelan commented 6 years ago

As far as I can see (however, I didn't test your branch yet) the implementation seems solid and your test are fine as well 👍 Thank you very much for your great work! Docs would be great, yes.

@scones As you and @iam-merlin came up with the idea of worker plugins - what do you think about this PR? Any suggestions or comments?

Best regards Andreas

merlindorin commented 6 years ago

@xelan thx for the feedback :D, from my point of view, this implementation have a main drawback : "is it really useful?".

I'll put more documentation and write a sample plugin in examples soon (the container injection will be an interesting one, 2 issues in one pull request :D)

scones commented 6 years ago

@xelan as stated earlier it is good.

Also i want to get this merged, so i can add other featured based on this.

xelan commented 6 years ago

Ok, then we're all at the same track. @iam-merlin Thank you again for your great work. Please just write a comment when the your examples/docs are done and the commits are squashed. Then I'll merge this PR soon.

xelan commented 6 years ago

How's the status here, can I help you with the docs @iam-merlin? If everything is ready, we could already include this feature in the next minor release 2.2.0.

xelan commented 6 years ago

Any news @iam-merlin? I can help you with the docs, but IMHO it's best if you briefly explain your plugin system, maybe with one or two practical examples.