| View previous topic :: View next topic |
| Author |
Message |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Wed Nov 14, 2012 5:38 pm Post subject: Finally finished my fucking queued task manager in PHP |
|
|
Well my first draft anyway. Why did I make a task manager in PHP? Fuck you, that's why. I want the task manager on the server to only have to execute one task, where after the application will handle the rest. This way you can ensure no tasks/jobs are ran simultaneously, and to ensure that the same task isn't asked to be performed when its previous instance is still running. This was build in the Zend Framework, because I like that framework in combination with PHP.
I've been working on this idea since yesterday after work, and so far I have a controller which needs to be called every minute of every day (will only loop through the folder with task classes to see if they need to be executed), an abstract class which holds almost all of the functionality so the actual task only has a few constants and a 'task()' method that require the developers' attention.
A new task class can be set to 'launch' from a certain date and time (up to the minute), for example on 2012-12-12 12:12, with the desired interval of days, hours, or minutes thereafter. A priority can also be given to the task, for when you need the faster tasks to be executed first, and the slower ones last. A timeout for a task can also be set in minutes and seconds.
# Controller - http://pastebin.com/jPAhtVAY
# Abstract - http://pastebin.com/uBKaPJxu
# Demo task - http://pastebin.com/Ewp4Mgyi
NOTE
In the abstract class I'm still not entirely satisfied with the serialization of the array containing the timestamp for when the script was last executed, and the writing to a file (although the reading and writing to a file is faster than a query to the DB). I feel like I could do without the serialization and just put a timestamp string in the file, but am doubtful because I might use the array to contain more information than it does now.
Second thing is the late static binding class call. Because I can't call it from a variable by using a set/get method, I have to call it within each method that makes use of it (currently two methods).
Finally, I realize that the date methods aren't entirely done right (setStartScript and setLastExecuted seem a bit redundant), which will be fixed.
PS: Nobody probably gives a shit, or will even respond, but I just had to share because talking about it gives me ideas. |
|
| Back to top |
|
 |
potaters Grandmaster Cheater
Reputation: 72
Joined: 13 Apr 2009 Posts: 969
|
Posted: Wed Nov 14, 2012 6:10 pm Post subject: |
|
|
| You went a little overboard on your commenting there. Nice script though. |
|
| Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Wed Nov 14, 2012 6:26 pm Post subject: |
|
|
| potaters wrote: | | You went a little overboard on your commenting there. Nice script though. |
I rather comment my code properly, than to write tiny easily misinterpreted sentences. That said I might have put a little too much into it. |
|
| Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Wed Nov 14, 2012 6:29 pm Post subject: |
|
|
Not bad, though you might want to improve your document on your functions. Use the @param and @return to signify the parameter and return type. Also include a small summary of expected use. Some people even document pre and post conditions. _________________
This is the inception of deception, checking the depth of your perception.
 |
|
| Back to top |
|
 |
potaters Grandmaster Cheater
Reputation: 72
Joined: 13 Apr 2009 Posts: 969
|
Posted: Wed Nov 14, 2012 6:42 pm Post subject: |
|
|
| Aniblaze wrote: | | potaters wrote: | | You went a little overboard on your commenting there. Nice script though. |
I rather comment my code properly, than to write tiny easily misinterpreted sentences. That said I might have put a little too much into it. |
I was aiming that more at putting your name in each comment. |
|
| Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Wed Nov 14, 2012 7:01 pm Post subject: |
|
|
| Aviar³ wrote: | | Not bad, though you might want to improve your document on your functions. Use the @param and @return to signify the parameter and return type. Also include a small summary of expected use. Some people even document pre and post conditions. |
I... I did. Except for the expected use one.
| potaters wrote: | | Aniblaze wrote: | | potaters wrote: | | You went a little overboard on your commenting there. Nice script though. |
I rather comment my code properly, than to write tiny easily misinterpreted sentences. That said I might have put a little too much into it. |
I was aiming that more at putting your name in each comment. |
If somebody else starts working on it (if I were to use this at work for example), than the author might differ with each method. |
|
| Back to top |
|
 |
|