-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added features. Worker execution and all files affected
- Loading branch information
Marc
committed
Dec 13, 2011
1 parent
c3f512d
commit 5823dcd
Showing
12 changed files
with
253 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +0,0 @@ | ||
<?php | ||
|
||
namespace Mmoreramerino\GearmanBundle\Command; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputDefinition; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
/** | ||
* Gearman Client Execute Command class | ||
* | ||
* @author Marc Morera <marc@ulabox.com> | ||
*/ | ||
class GearmanClientExecuteCommand extends ContainerAwareCommand | ||
{ | ||
/** | ||
* Console Command configuration | ||
*/ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
$this->setName('gearman:client:execute') | ||
->setDescription('Test') | ||
->addArgument('job', InputArgument::REQUIRED, 'job to execute'); | ||
} | ||
|
||
/** | ||
* Executes the current command. | ||
* | ||
* @param InputInterface $input An InputInterface instance | ||
* @param OutputInterface $output An OutputInterface instance | ||
* | ||
* @return integer 0 if everything went fine, or an error code | ||
* | ||
* @throws \LogicException When this abstract class is not implemented | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$job = $input->getArgument('job'); | ||
$this->getContainer()->get('gearman')->callJob($job); | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Mmoreramerino\GearmanBundle\Command; | ||
|
||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputDefinition; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
|
||
/** | ||
* Gearman Job Describe Command class | ||
* | ||
* @author Marc Morera <marc@ulabox.com> | ||
*/ | ||
class GearmanWorkerDescribeCommand extends ContainerAwareCommand | ||
{ | ||
/** | ||
* Console Command configuration | ||
*/ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
$this->setName('gearman:worker:describe') | ||
->setDescription('Describe given worker') | ||
->addArgument('worker', InputArgument::REQUIRED, 'worker to describe'); | ||
} | ||
|
||
/** | ||
* Executes the current command. | ||
* | ||
* @param InputInterface $input An InputInterface instance | ||
* @param OutputInterface $output An OutputInterface instance | ||
* | ||
* @return integer 0 if everything went fine, or an error code | ||
* | ||
* @throws \LogicException When this abstract class is not implemented | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$worker = $input->getArgument('worker'); | ||
$worker = $this->getContainer()->get('gearman')->getWorker($worker); | ||
$this->getContainer()->get('gearman.describer')->describeWorker($output, $worker); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Mmoreramerino\GearmanBundle\Exceptions; | ||
|
||
/** | ||
* GearmanBundle can't find worker specified as Gearman format Exception | ||
* | ||
* @author Marc Morera <marc@ulabox.com> | ||
*/ | ||
class WorkerDoesNotExistException extends \Exception | ||
{ | ||
|
||
/** | ||
* Construct method for Exception | ||
* | ||
* @param string $worker Worker name to be shown in Exception | ||
* @param integer $code Code of exception | ||
* @param \Exception $previous Previos Exception | ||
*/ | ||
public function __construct($worker, $code = 0, \Exception $previous = null) | ||
{ | ||
$message = 'GearmanBundle can\'t find worker with name ' . $worker . PHP_EOL; | ||
parent::__construct($message, $code, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.