// If keeping the history of this help session is important, we could mark it as dequeued // instead. If we had authentication for the representative, then we could also mark the // help session with the identity of the representative. $redisResponse = $redis->del($helpSessionKey); if (!handleRedisError($redisResponse, $app, 'Não foi possível remover a sessão após a retirada da fila.')) { return; } $app->response->headers->set('Content-Type', 'application/json'); $app->response->setBody(json_encode($responseData)); } }); // Customer dequeues by cancelling or leaving the page // // Dequeue the specific help session from the help queue. $app->delete('/help/queue/:queueId', function ($queueId) use($app, $redis) { $redisResponse = $redis->lrem(HELP_QUEUE_KEY, 0, $queueId); if (!handleRedisError($redisResponse, $app, 'Não foi possível remover a sessão da fila de atendimento.')) { return; } $helpSessionKey = $queueId; $redisResponse = $redis->del($helpSessionKey); if (!handleRedisError($redisResponse, $app, 'Não foi possível remover a sessão após a retirada da fila.')) { return; } $app->response->setStatus(204); }); /* ------------------------------------------------------------------------------------------------ * Application Start * -----------------------------------------------------------------------------------------------*/ $app->run(); /* ------------------------------------------------------------------------------------------------
$redis = new Predis\Client(array('read_write_timeout' => 0)); while ($body = $redis->brpoplpush('dflydev-git-subsplit:incoming', 'dflydev-git-subsplit:processing', 0)) { $data = json_decode($body, true); $name = null; $project = null; $data['dflydev_git_subsplit'] = array('processed_at' => time()); foreach ($config['projects'] as $testName => $testProject) { if ($testProject['url'] === $data['repository']['url']) { $name = $testName; $project = $testProject; break; } } if (null === $name) { print sprintf('Skipping request for URL %s (not configured)', $data['repository']['url']) . "\n"; $redis->lrem('dflydev-git-subsplit:processing', 1, $body); $redis->lpush('dflydev-git-subspilt:failures', json_encode($data)); continue; } $data['dflydev_git_subsplit']['name'] = $name; $data['dflydev_git_subsplit']['project'] = $project; $ref = $data['ref']; $publishCommand = array('git subsplit publish', escapeshellarg(implode(' ', $project['splits']))); if (preg_match('/refs\\/tags\\/(.+)$/', $ref, $matches)) { $publishCommand[] = escapeshellarg('--rebuild-tags'); $publishCommand[] = escapeshellarg('--no-heads'); $publishCommand[] = escapeshellarg(sprintf('--tags=%s', $matches[1])); } elseif (preg_match('/refs\\/heads\\/(.+)$/', $ref, $matches)) { $publishCommand[] = escapeshellarg('--no-tags'); $publishCommand[] = escapeshellarg(sprintf('--heads=%s', $matches[1])); } else {
public function getDeleteQueuedJob($id) { if (!\Auth::isSuperUser()) { App::abort(404); } // Get the Redis JobID from the databse for this jib $redis_job_id = \SeatQueueInformation::where('id', $id)->pluck('jobID'); // Connect to redis and loop over the queued jobs, looking for the job $redis = new Predis\Client(array('host' => Config::get('database.redis.default.host'), 'port' => Config::get('database.redis.default.port'))); // Loop over the jobs in redis, looking for the one we want to delete foreach ($redis->lrange('queues:default', 0, -1) as $redis_job) { // Delete it if we match the jobID if (strpos($redis_job, $redis_job_id)) { $redis->lrem('queues:default', 0, $redis_job); } } // Delete if from the database too \SeatQueueInformation::where('status', 'Queued')->where('id', $id)->delete(); return Response::json(); }