[Spwn] add Resque job dispatcher to lunr

Review Request #25 — Created Dec. 18, 2012 and submitted

olivier
Lunr
https://github.com/owizen/lunr/tree/dispatcher
lunr
Add a backgroundjob dispatcher to lunr for Resque 
Unit test, 100% covering
  • 1
  • 0
  • 28
  • 1
  • 30
Description From Last Updated
Dude, this is still an incompatible method signature... How often do I have to mention this? pprkut pprkut
pprkut
  1. 
      
  2. The issue has been resolved. Show all issues
    Dependency Injection
  3. The issue has been resolved. Show all issues
    missing destruction of $resque
  4. system/libraries/spwn/class.resquejobdispatcher.inc.php (Diff revision 1)
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues
    I'd rather have $queue a default queue than NULL
    1. Yep good Idea, you can tell the workers to work on all available
  5. tests/system/libraries/spwn/class.resquejobdispatcher.dispatch.test.php (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues
    Two methods don't really warrant a new test file. Just have one test file for the whole class, same as we do for various other small classes.
  6. The issue has been resolved. Show all issues
    That's a ReflectionClass
  7. The issue has been resolved. Show all issues
    I don't see why this is necessary. The Mock should have already replaced this with an empty method block...
  8. The issue has been resolved. Show all issues
    that's a bit long of a variable name, no?
    1. rename to dispatcher then 
  9. 
      
olivier
pprkut
  1. 
      
  2. The issue has been resolved. Show all issues
    That needs better documentation
  3. The issue has been resolved. Show all issues
    mention it's optional
  4. The issue has been resolved. Show all issues
    erm....
  5. The issue has been resolved. Show all issues
    what would that be in the case of a CliBackgroundJob?
  6. The issue has been resolved. Show all issues
    This signature is incompatible to:
    
    public static function enqueue($queue, $class, $args = null, $trackStatus = false)
  7. The issue has been resolved. Show all issues
    don't pass the mock without keeping a reference
  8. The issue has been resolved. Show all issues
    reuse the reference
  9. The issue has been resolved. Show all issues
    reuse the existing reference
  10. 
      
olivier
pprkut
  1. 
      
  2. The issue has been resolved. Show all issues
    unused
  3. system/libraries/spwn/class.resquejobdispatcher.inc.php (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues
    I'm not sure this is the correct naming here. Cli won't have that functionality, but for Resque it's wrong since you just get the Job ID not the result.
  4. The issue has been resolved. Show all issues
    not tested
  5. The issue has been resolved. Show all issues
    wrong copyright
  6. tests/mocks/libraries/spwn/class.resque.mock.php (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    The issue has been resolved. Show all issues
    still invalid signature
  7. 
      
olivier
pprkut
  1. 
      
  2. tests/mocks/libraries/spwn/class.resque.mock.php (Diff revision 4)
     
     
     
     
     
    An issue was opened. Show all issues
    Dude, this is still an incompatible method signature...
    How often do I have to mention this?
  3. 
      
olivier
olivier
pprkut
  1. 
      
  2. src/Lunr/Spwn/ResqueJobDispatcher.php (Diff revision 6)
     
     
     
    The issue has been resolved. Show all issues
    Coding style
  3. src/Lunr/Spwn/ResqueJobDispatcher.php (Diff revision 6)
     
     
     
     
    Thought: How about making those setters?
    Most of the time you probably dispatch similar jobs in a loop, then setting the queue and track status once makes for an easier interface than having to pass it all the time. What do you think?
    1. The idea is good, for a CLI job dispatcher, the queue will be the script name.
      For the trackStatus, it could give the possibility to get the exit code of the process for CLI
      the get_job_id should then be rename to a more global name covering all the possibilities.
    2. That the queue will be the script name is an assumption I would not make.
      Using trackstatus for the cli exit code seems like a sensible choice, however I do not follow with get_job_id. What do you mean exactly?
    3. Right for the queue, it is not the job and the job is the script, I talked too fast.
      
      For the get_job_id, that method should return the resque token or the exit code returned by CLI
      but by thinking back to this (was already discussed I think), having the exit code is not possible for background job...
      
      I made a little test and it doesn't work, BUT it seems that the exec function allows us to get the output of the process as an array
      and it works with background tasks.
      
    4. Right, but we also said that you don't want the output of a cli background task, since waiting for the output basically doesn't make it run in the background anymore.
      Additionally, the job id is not the equivalent of the exit code, it would be the process id. The exit code would be equivalent to the return value.
  4. The issue has been resolved. Show all issues
    wrong namespace
  5. The issue has been resolved. Show all issues
    out of date
    1. Will be corrected
  6. src/Lunr/Spwn/Tests/ResqueJobDispatcherTest.php (Diff revision 6)
     
     
     
     
    The issue has been resolved. Show all issues
    I don't like that. Please do that explicitely in the tests
    1. You mean moving it to the test case instead of the setUp method?
      Will be done so then
    2. Yes. There are some cases where $this->any() in setUp is preferable. I'm not sure that's the case here though.
  7. 
      
olivier
olivier
pprkut
  1. 
      
  2. src/Lunr/Spwn/Tests/ResqueJobDispatcherTest.php (Diff revisions 7 - 8)
     
     
     
     
    The issue has been resolved. Show all issues
    what's the difference between these that you have to test all of them?
  3. The issue has been resolved. Show all issues
    assertFalse....
  4. The issue has been resolved. Show all issues
    assertSame
  5. The issue has been resolved. Show all issues
    assertNotSame
  6. tests/phpunit.xml (Diff revisions 7 - 8)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    The issue has been dropped. Show all issues
    what's this?
  7. 
      
olivier
olivier
Review request changed

Status: Closed (submitted)

Change Summary:

Merged into master
Loading...