• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Queue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: boot

 public function boot()
 {
     $this->package('orlissenberg/laravel-zendserver-pushqueue');
     // 1. Need a route to marshal requests.
     \Route::any("/queue/zendserver", function () {
         /** @var ZendJobQueue $connection */
         $connection = \Queue::connection("zendjobqueue");
         $connection->marshal();
     });
     // 2. Add the connector to the Queue facade.
     \Queue::addConnector("zendserver", function () {
         return app()->make("\\Orlissenberg\\Queue\\Connectors\\ZendJobQueueConnector");
     });
     // 3. Add configuration to the app/config/queue.php
     /*
     'zendjob' => [
         'driver' => 'zendserver',
         'options' => [],
         'callback-url' => '/queue/zendserver',
     ],
     */
     // 4. Enable the test route (optional for testing only)
     /*
     \Route::get(
         "/queue/zendtest",
         function () {
             $connection = \Queue::connection("zendjobqueue");
             $connection->push("\\Orlissenberg\\Queue\\Handlers\\TestHandler@handle", ["laravel4" => "rocks"]);
     
             return "Job queued.";
         }
     );
     */
 }
开发者ID:orlissenberg,项目名称:laravel-zendserver-pushqueue,代码行数:34,代码来源:ZendJobQueueServiceProvider.php


示例17: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // message
     $data = array('type' => $this->argument('type'), 'id' => $this->argument('id'), 'date' => $this->argument('date'));
     // add message to queue
     Queue::push("Scraper", $data);
 }
开发者ID:Tjoosten,项目名称:harvester,代码行数:12,代码来源:ManualQueueCommand.php


示例18: dispatch

 public function dispatch(Queue $queue)
 {
     $snippets = $this->prepareForDispatch($queue->flush());
     if (count($snippets) > 0) {
         $this->log('Snippets found in the queue, preparing POST request');
         try {
             $payload = array('type' => Phpconsole::TYPE, 'version' => Phpconsole::VERSION, 'snippets' => $snippets);
             $this->client->send($payload);
             $this->log('Request successfully sent to the API endpoint');
         } catch (\Exception $e) {
             $this->log('Request failed. Exception message: ' . $e->getMessage(), true);
         }
     } else {
         $this->log('No snippets found in the queue, dispatcher exits', true);
     }
 }
开发者ID:usabilitydynamics,项目名称:wp-php-console,代码行数:16,代码来源:Dispatcher.php


示例19: postEdit

 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit A Modpack Code - ' . $this->site_name;
     $input = Input::only('name', 'deck', 'description', 'slug');
     $modpacktag = ModpackTag::find($id);
     $messages = ['unique' => 'This modpack tag already exists in the database!'];
     $validator = Validator::make($input, ['name' => 'required|unique:modpack_tags,name,' . $modpacktag->id, 'deck' => 'required'], $messages);
     if ($validator->fails()) {
         return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $modpacktag->name = $input['name'];
     $modpacktag->deck = $input['deck'];
     $modpacktag->description = $input['description'];
     $modpacktag->last_ip = Request::getClientIp();
     if ($input['slug'] == '' || $input['slug'] == $modpacktag->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $modpacktag->slug = $slug;
     $success = $modpacktag->save();
     if ($success) {
         Cache::tags('modpacks')->flush();
         Queue::push('BuildCache');
         return View::make('tags.modpacks.edit', ['title' => $title, 'success' => true, 'modpacktag' => $modpacktag]);
     }
     return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack code.'])->withInput();
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:31,代码来源:ModpackTagController.php


示例20: placeNodeInLimbo

 public function placeNodeInLimbo($node_id, $integration_id)
 {
     $node = Node::find($node_id);
     $node->limbo = true;
     Queue::push('DeployAgentToNode', array('message' => array('node_id' => $node_id, 'integration_id' => $integration_id)));
     $node->save();
 }
开发者ID:crudbug,项目名称:Dashboard,代码行数:7,代码来源:NodesController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP QueueClient类代码示例发布时间:2022-05-23
下一篇:
PHP QuestionGroup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap