[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. Dependency Injection
  3. missing destruction of $resque
  4. system/libraries/spwn/class.resquejobdispatcher.inc.php (Diff revision 1)
     
     
     
     
     
     
     
    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)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    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. That's a ReflectionClass
  7. I don't see why this is necessary. The Mock should have already replaced this with an empty method block...
  8. that's a bit long of a variable name, no?
    1. rename to dispatcher then 
  9. 
      
olivier
pprkut
  1. 
      
  2. That needs better documentation
  3. mention it's optional
  4. what would that be in the case of a CliBackgroundJob?
  5. This signature is incompatible to:
    
    public static function enqueue($queue, $class, $args = null, $trackStatus = false)
  6. don't pass the mock without keeping a reference
  7. reuse the existing reference
  8. 
      
olivier
pprkut
  1. 
      
  2. system/libraries/spwn/class.resquejobdispatcher.inc.php (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
    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.
  3. not tested
  4. wrong copyright
  5. tests/mocks/libraries/spwn/class.resque.mock.php (Diff revision 3)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    still invalid signature
  6. 
      
olivier
pprkut
  1. 
      
  2. tests/mocks/libraries/spwn/class.resque.mock.php (Diff revision 4)
     
     
     
     
     
    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)
     
     
     
    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. wrong namespace
  5. out of date
  6. src/Lunr/Spwn/Tests/ResqueJobDispatcherTest.php (Diff revision 6)
     
     
     
     
    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)
     
     
     
     
    what's the difference between these that you have to test all of them?
  3. assertFalse....
  4. assertSame
  5. assertNotSame
  6. tests/phpunit.xml (Diff revisions 7 - 8)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    what's this?
  7. 
      
olivier
olivier
Review request changed

Status: Closed (submitted)

Change Summary:

Merged into master
Loading...