Comments (5)
Is there a reason why the setUp/tearDown methods are not needed? Guess removing complexity does make sense. I’m not sure if constructing a class makes any difference, since I would prefer to use the Job class as a wrapper and call out to other services inside the Job::perform() method, rather than fuss with code in that class itself.
from php-resque.
👍
This totally makes sense to me, as we're registering classes as jobs.
The BC break is the big issue here, though.
from php-resque.
In my own code i wanted to pull jobs out of a dependency injection container, to do that i added a createInstance event, and used the event to implement my own instance creation. The event could similarly be used to hook in a backwards compatible instantiator, that checks method existance and overrides the fixed implementation if the class hasn't been updated. #51
from php-resque.
Realizing that this issue is old, I'd still like to weigh in real quick. I tend to agree with @maetl that I prefer to use the Job class as a wrapper for more complex classes, though I take it a step further and say that plugging in a class that isn't specifically designed for use as a Resque Job class is a bad idea in itself. The current functionality differs from that of the Ruby original, but tends to be more in line with the needs of PHP development that way, just as the Ruby version tends to be in line with development paradigms there.
from php-resque.
Hey, @chrisboulton - is this still something you'd like to see? We're in the middle of putting in so much backward-compatibility-breaking functionality already that we almost might as well just do this now, unless you've changed your mind in the couple of years since creating this issue.
Actually, it might not be too difficult to keep backward compatibility and still move this direction... We could create an interface (say, Resque_Job_Interface
) that specifies just one method (say, public static function perform($job, $args, $queue)
) and then check whether the job class implements that interface and proceed accordingly (say, if (is_a($this->payload['class'], 'Resque_Job_Interface', TRUE)) {...} else {...}
). Any job implementing the new interface can be called statically, bypassing setUp()
and tearDown()
and so forth, while jobs that don't implement the interface are instantiated according to the existing model. We would of course deprecate the old approach, then remove it entirely in a year or two.
At any rate, that depends on whether we still want to move that direction. There are advantages either way.
from php-resque.
Related Issues (20)
- The project has been abandoned? HOT 8
- Is it possible to add a job if it does not exists?
- Job Not Found Error specifications
- Could add a event before work reserve
- QUEUE=mail: Command not found. HOT 2
- Still job not found HOT 4
- Couldnt change the redis host while running the worker HOT 2
- 为什么不增加 redis Auth HOT 1
- event listener for any job HOT 1
- Resque_Job_Status Throughout STATUS_RUNNING
- PHP Warning: fread(): Length parameter must be greater than 0 HOT 2
- Please archive this repository -> This package is abandoned and no longer maintained. The author suggests using the resque/php-resque package instead. HOT 7
- QUEUE=message php vendor/bin/resque HOT 4
- add delay jobs HOT 1
- should check pcntl_wifexited first before pcntl_wexitstatus
- 项目还有人维护吗? HOT 3
- Why not "break"? HOT 1
- The documentation for 'scan' is described HOT 6
- Stat namespace growing
- PHP Deprecated: implode(): Passing glue string after array is deprecated.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-resque.