当前位置: 首页>>代码示例>>PHP>>正文


PHP Queue类代码示例

本文整理汇总了PHP中Queue的典型用法代码示例。如果您正苦于以下问题:PHP Queue类的具体用法?PHP Queue怎么用?PHP Queue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Queue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: queueGetter

function queueGetter($conn, $condition)
{
    try {
        if (empty($condition)) {
            $tsql = "SELECT [id],[Name],[Location] FROM dbo.Queue";
        } else {
            $tsql = "SELECT [id],[Name],[Location] FROM dbo.Queue WHERE {$condition}";
        }
        $conn = OpenConnection();
        $getQueues = sqlsrv_query($conn, $tsql);
        if ($getQueues == FALSE) {
            echo "Error!!<br>";
            die(print_r(sqlsrv_errors(), true));
        }
        while ($row = sqlsrv_fetch_array($getQueues, SQLSRV_FETCH_ASSOC)) {
            $queue = new Queue($row['Name'], $row['Location']);
            $queue->setId($row['id']);
            $queues[] = $queue;
        }
        sqlsrv_free_stmt($getQueues);
        sqlsrv_close($conn);
        if (!empty($queues)) {
            return $queues;
        } else {
            return null;
        }
    } catch (Exception $e) {
        echo "Get Queue Error!";
    }
}
开发者ID:jyoansah,项目名称:bostonhacks15,代码行数:30,代码来源:DBMethods.php

示例2: actionIndex

 /**
  * @param int $limit
  */
 public function actionIndex($limit = 5)
 {
     $limit = (int) $limit;
     $this->log("Try process {$limit} mail tasks...");
     $queue = new Queue();
     $models = $queue->getTasksForWorker(self::MAIL_WORKER_ID, $limit);
     $this->log("Find " . count($models) . " new mail task");
     foreach ($models as $model) {
         $this->log("Process mail task id = {$model->id}");
         $data = $model->decodeJson();
         if (!$data) {
             $model->completeWithError('Error json_decode', CLogger::LEVEL_ERROR);
             $this->log("Error json_decode");
             continue;
         }
         if (!isset($data['from'], $data['to'], $data['theme'], $data['body'])) {
             $model->completeWithError('Wrong data...');
             $this->log('Wrong data...', CLogger::LEVEL_ERROR);
             continue;
         }
         $from = $this->from ? $this->from : $data['from'];
         $replyTo = isset($data['replyTo']) ? $data['replyTo'] : [];
         $sender = Yii::app()->getComponent($this->sender);
         if ($sender->send($from, $data['to'], $data['theme'], $data['body'], false, $replyTo)) {
             $model->complete();
             $this->log("Success send mail");
             continue;
         }
         $this->log('Error sending email', CLogger::LEVEL_ERROR);
     }
 }
开发者ID:yupe,项目名称:yupe,代码行数:34,代码来源:YQueueMailSenderCommand.php

示例3: buildResponse

 /**
  * Converts the response in JSON format to the value object i.e Queue
  *
  * @param json
  *            - response in JSON format
  *
  * @return Queue object filled with json data
  *
  */
 function buildResponse($json)
 {
     $queuesJSONObj = $this->getServiceJSONObject("queues", $json);
     $queueJSONObj = $queuesJSONObj->__get("queue");
     $queue = new Queue();
     $queue->setStrResponse($json);
     $queue->setResponseSuccess($this->isRespponseSuccess($json));
     $this->buildObjectFromJSONTree($queue, $queueJSONObj);
     if (!$queueJSONObj->has("messages")) {
         return $queue;
     }
     if (!$queueJSONObj->__get("messages")->has("message")) {
         return $queue;
     }
     if ($queueJSONObj->__get("messages")->__get("message") instanceof JSONObject) {
         // Single Entry
         $messageObj = new QueueMessage($queue);
         $this->buildObjectFromJSONTree($messageObj, $queueJSONObj->__get("messages")->__get("message"));
     } else {
         // Multiple Entry
         $messagesJSONArray = $queueJSONObj->getJSONObject("messages")->getJSONArray("message");
         for ($i = 0; $i < count($messagesJSONArray); $i++) {
             $messageJSONObj = $messagesJSONArray[$i];
             $messageObj = new QueueMessage($queue);
             $messageJSONObj = new JSONObject($messageJSONObj);
             $this->buildObjectFromJSONTree($messageObj, $messageJSONObj);
         }
     }
     return $queue;
 }
开发者ID:murnieza,项目名称:App42_PHP_SDK,代码行数:39,代码来源:QueueResponseBuilder.php

示例4: work

 public static function work(&$controllerContext, &$viewContext)
 {
     $queue = new Queue(Config::$userQueuePath);
     $queueItem = new QueueItem(strtolower($controllerContext->userName));
     $j['user'] = $controllerContext->userName;
     $j['pos'] = $queue->seek($queueItem);
     $viewContext->layoutName = 'layout-json';
     $viewContext->json = $j;
 }
开发者ID:Lucas8x,项目名称:graph,代码行数:9,代码来源:UserControllerQueuePositionModule.php

示例5: testConsumeViaQueue

 public function testConsumeViaQueue()
 {
     $this->markTestSkipped('Consuming via queue does not work');
     $this->consumerTopic->consumeQueueStart(self::PARTITION, RD_KAFKA_OFFSET_BEGINNING, $this->queue);
     $this->consumerTopic->consume(self::PARTITION, 100);
     $this->consumerTopic->consumeStop(self::PARTITION);
     $message = $this->queue->consume(200);
     $this->assertInstanceOf(Message::class, $message);
 }
开发者ID:kwn,项目名称:php-rdkafka-stubs,代码行数:9,代码来源:QueueTest.php

示例6: getMqsLength

function getMqsLength($queuename)
{
    include SERVER_ROOT . "libs/alimqs.class.php";
    $QueueObj = new Queue('84KTqRKsyBIYnVJt', 'u72cpnMTt2mykMMluafimbhv5QD3uC', 'crok2mdpqp', 'mqs-cn-hangzhou.aliyuncs.com');
    $info = $QueueObj->Getqueueattributes($queuename);
    if ($info['state'] == 'ok') {
        return $info['msg']['ActiveMessages'];
    }
    return false;
}
开发者ID:huqq1987,项目名称:clone-lemon,代码行数:10,代码来源:functions.php

示例7: __construct

 /**
  * Constructor
  *
  * @param string $worker function name
  * @param mixed $chanData
  */
 public function __construct($worker, $chanData = null)
 {
     if ($chanData && is_array($chanData)) {
         foreach ($chanData as $chanId => $jobs) {
             $Q = new Queue($worker);
             $Q->addJobs($jobs);
             $this->chan[$chanId] = $Q;
         }
     }
 }
开发者ID:shaogx,项目名称:easyJob,代码行数:16,代码来源:Chan.php

示例8: preWork

 public static function preWork(&$controllerContext, &$viewContext)
 {
     $controllerContext->cache->setPrefix($controllerContext->userName);
     if (BanHelper::getUserBanState($controllerContext->userName) == BanHelper::USER_BAN_TOTAL) {
         $controllerContext->cache->bypass(true);
         $viewContext->userName = $controllerContext->userName;
         $viewContext->viewName = 'error-user-blocked';
         $viewContext->meta->title = 'User blocked &#8212; ' . Config::$title;
         return;
     }
     $module = $controllerContext->module;
     HttpHeadersHelper::setCurrentHeader('Content-Type', $module::getContentType());
     $viewContext->media = $controllerContext->media;
     $viewContext->module = $controllerContext->module;
     $viewContext->meta->noIndex = true;
     $viewContext->contentType = $module::getContentType();
     if ($viewContext->contentType != 'text/html') {
         $viewContext->layoutName = 'layout-raw';
     }
     Database::selectUser($controllerContext->userName);
     $user = R::findOne('user', 'LOWER(name) = LOWER(?)', [$controllerContext->userName]);
     if (empty($user)) {
         if (!isset($_GET['referral']) || $_GET['referral'] !== 'search') {
             $controllerContext->cache->bypass(true);
             $viewContext->userName = $controllerContext->userName;
             $viewContext->viewName = 'error-user-not-found';
             $viewContext->meta->title = 'User not found &#8212; ' . Config::$title;
             return;
         }
         $queue = new Queue(Config::$userQueuePath);
         $queueItem = new QueueItem(strtolower($controllerContext->userName));
         $queue->enqueue($queueItem);
         $viewContext->queuePosition = $queue->seek($queueItem);
         $controllerContext->cache->bypass(true);
         //try to load cache, if it exists
         $url = $controllerContext->url;
         if ($controllerContext->cache->exists($url)) {
             $controllerContext->cache->load($url);
             flush();
             $viewContext->layoutName = null;
             $viewContext->viewName = null;
             return;
         }
         $viewContext->userName = $controllerContext->userName;
         $viewContext->viewName = 'error-user-enqueued';
         $viewContext->meta->title = 'User enqueued &#8212; ' . Config::$title;
         return;
     }
     $viewContext->user = $user;
     $viewContext->meta->styles[] = '/media/css/menu.css';
     $viewContext->updateWait = Config::$userQueueMinWait;
     $module = $controllerContext->module;
     $module::preWork($controllerContext, $viewContext);
 }
开发者ID:Lucas8x,项目名称:graph,代码行数:54,代码来源:UserController.php

示例9: testAddItemEmpty

 /**
  * @dataProvider providerAddItemsEmpty
  */
 public function testAddItemEmpty($invalidItem = null)
 {
     $queue = new Queue($this->redis, 'test');
     $queue->addItem(1);
     try {
         $queue->addItem($invalidItem);
         $this->fail('Expected \\PhpRQ\\Exception\\InvalidArgument to be thrown');
     } catch (Exception\InvalidArgument $e) {
     }
     $this->assertSame(['1'], $this->redis->lrange('test', 0, 5));
     $this->assertKeys(['test']);
 }
开发者ID:jannavratil,项目名称:php-rq,代码行数:15,代码来源:UniqueQueueTest.php

示例10: load_view

function load_view($id)
{
    global $cp;
    $objQueue = new Queue();
    $objQueue->setUid($id);
    if ($objQueue->load()) {
        $cp->set_data(nl2br($objQueue->getBbs('description')));
    } else {
        $cp->set_data('item not found!');
    }
    return;
}
开发者ID:window98lsq,项目名称:autoweb,代码行数:12,代码来源:cpaint.queue.php

示例11: enqueueOnce

 public function enqueueOnce(Job $job, $trackStatus = false)
 {
     $queue = new Queue($job->queue);
     $jobs = $queue->getJobs();
     foreach ($jobs as $j) {
         if ($j->job->payload['class'] == get_class($job)) {
             if (count(array_intersect($j->args, $job->args)) == count($job->args)) {
                 return $trackStatus ? $j->job->payload['id'] : null;
             }
         }
     }
     return $this->enqueue($job, $trackStatus);
 }
开发者ID:rosstuck,项目名称:BCCResqueBundle,代码行数:13,代码来源:Resque.php

示例12: work

 public static function work(&$controllerContext, &$viewContext)
 {
     $queue = new Queue(Config::$userQueuePath);
     $queueItem = new QueueItem(strtolower($controllerContext->userName));
     $user = R::findOne('user', 'LOWER(name) = LOWER(?)', [$controllerContext->userName]);
     $profileAge = time() - strtotime($user->processed);
     $banned = BanHelper::getUserBanState($controllerContext->userName) != BanHelper::USER_BAN_NONE;
     if ($profileAge > Config::$userQueueMinWait and !$banned && Config::$enqueueEnabled) {
         $queue->enqueue($queueItem);
     }
     $j['user'] = $controllerContext->userName;
     $j['pos'] = $queue->seek($queueItem);
     $viewContext->layoutName = 'layout-json';
     $viewContext->json = $j;
 }
开发者ID:asmdz,项目名称:malgraph,代码行数:15,代码来源:UserControllerQueueAddModule.php

示例13: byQueue

 public function byQueue($qid)
 {
     if (is_array($qid)) {
         $obj = new Queue($qid);
         $obj->setTimePeriod($this->startEpoch, $this->endEpoch);
         $obj->setAgent($this->agent);
         return $obj;
     } else {
         if (@is_object($this->qobjects[$qid])) {
             return $this->qobjects[$qid];
         } else {
             return false;
         }
     }
 }
开发者ID:avinaszh,项目名称:vicidial-agent-reporting,代码行数:15,代码来源:class.Campaign_Inbound.php

示例14: addToQueque

 /**
  * 
  * @param string $type
  * @param string $description
  * @param string $function
  * @param array $args
  * @param int $priority
  * @return type
  */
 static function addToQueque($type, $description, $function, $args, $priority = 0)
 {
     $queue = new Queue();
     $queue->setCreatedAt(time());
     $queue->setStatus(self::STATUS_QUEUED);
     $queue->setArguments(serialize($args));
     $queue->setFunction($function);
     $queue->setType($type);
     $queue->setDescription($description);
     $queue->setPriority($priority);
     return $queue->save();
 }
开发者ID:jeffreycai,项目名称:reader,代码行数:21,代码来源:Queue.class.php

示例15: addToQueue

 public static function addToQueue($queue, $ownerID, $vCode, $api, $scope)
 {
     // Prepare the auth array
     if ($vCode != null) {
         $auth = array('keyID' => $ownerID, 'vCode' => $vCode);
     } else {
         $auth = array();
     }
     // Check the databse if there are jobs outstanding ie. they have the status
     // Queued or Working. If not, we will queue a new job, else just capture the
     // jobID and return that
     $jobID = \SeatQueueInformation::where('ownerID', '=', $ownerID)->where('api', '=', $api)->whereIn('status', array('Queued', 'Working'))->first();
     // Check if the $jobID was found, else, queue a new job
     if (!$jobID) {
         $jobID = \Queue::push($queue, $auth);
         \SeatQueueInformation::create(array('jobID' => $jobID, 'ownerID' => $ownerID, 'api' => $api, 'scope' => $scope, 'status' => 'Queued'));
     } else {
         // To aid in potential capacity debugging, lets write a warning log entry so that a user
         // is able to see that a new job was not submitted
         \Log::warning('A new job was not submitted due a similar one still being outstanding. Details: ' . $jobID, array('src' => __CLASS__));
         // Set the jobID to the ID from the database
         $jobID = $jobID->jobID;
     }
     return $jobID;
 }
开发者ID:boweiliu,项目名称:seat,代码行数:25,代码来源:helpers.php


注:本文中的Queue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。