/** * Test that the worker is an instance of the correct object * * @return void */ public function testGetEngine() { Log::config('stdout', ['engine' => 'File']); Queue::config('default', ['url' => 'mysql://*****:*****@localhost:80/database']); $logger = new NullLogger(); $this->shell->params['config'] = 'default'; $engine = $this->shell->getEngine($logger); $this->assertInstanceOf('josegonzalez\\Queuesadilla\\Engine\\MysqlEngine', $engine); }
/** * Retrieves a queue engine * * @param \Psr\Log\LoggerInterface $logger logger * @return \josegonzalez\Queuesadilla\Engine\Base */ public function getEngine($logger) { $config = Hash::get($this->params, 'config'); $engine = Queue::engine($config); $engine->setLogger($logger); if (!empty($this->params['queue'])) { $engine->config('queue', $this->params['queue']); } return $engine; }
/** * Retrieves a queue worker * * @param \josegonzalez\Queuesadilla\Engine\Base $engine engine to run * @param \Psr\Log\LoggerInterface $logger logger * @return \josegonzalez\Queuesadilla\Worker\Base */ public function getWorker($engine, $logger) { $worker = parent::getWorker($engine, $logger); $worker->attachListener('Worker.job.exception', function ($event) { $exception = $event->data['exception']; $exception->job = $event->data['job']; $sentryHandler = new SentryHandler(); $sentryHandler->handle($exception); }); $worker->attachListener('Worker.job.success', function ($event) { ConnectionManager::get('default')->disconnect(); }); $worker->attachListener('Worker.job.failure', function ($event) { $failedJob = $event->data['job']; $failedItem = $failedJob->item(); $options = ['queue' => 'failed', 'failedJob' => $failedJob]; Queue::push($failedItem['class'], $failedJob->data(), $options); ConnectionManager::get('default')->disconnect(); }); return $worker; }
/** * Ensure you cannot reconfigure a log adapter. * * @expectedException \BadMethodCallException * @return void */ public function testConfigErrorOnReconfigure() { Queue::config('tests', ['url' => 'mysql://*****:*****@localhost:80/database']); Queue::config('tests', ['url' => 'null://']); }
*/ //Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); //Inflector::rules('irregular', ['red' => 'redlings']); //Inflector::rules('uninflected', ['dontinflectme']); //Inflector::rules('transliteration', ['/å/' => 'aa']); /* * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call * Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more * advanced ways of loading plugins * * Plugin::loadAll(); // Loads all plugins at once * Plugin::load('Migrations'); //Loads a single plugin named Migrations * */ /* * Only try to load DebugKit in development mode * Debug Kit should not be installed on a production system */ if (Configure::read('debug')) { Plugin::load('DebugKit', ['bootstrap' => true]); } // Handle the CakeQueuesadilla Plugin::load('Josegonzalez/CakeQueuesadilla'); \Josegonzalez\CakeQueuesadilla\Queue\Queue::config(Configure::consume('Queuesadilla')); Plugin::load('AssetCompress', ['bootstrap' => true]); Plugin::load('BootstrapUI'); Plugin::load('Crud'); Plugin::load('CrudView'); Plugin::load('Josegonzalez/Upload'); Plugin::load('Migrations'); Plugin::load('Search');
/** * Push a single job onto the queue. * * @param string $callable a job callable * @param array $args an array of data to set for the job * @param array $options an array of options for publishing the job * @return bool the result of the push */ protected function push($callable, $args = [], $options = []) { return Queue::push($callable, $args, $options); }