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


PHP QueueManager类代码示例

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


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

示例1: onEndInitializeQueueManager

 /**
  * Register our queue handlers
  *
  * @param QueueManager $qm Current queue manager
  *
  * @return boolean hook value
  */
 function onEndInitializeQueueManager($qm)
 {
     $qm->connect('siterem', 'SiteConfirmReminderHandler');
     $qm->connect('uregrem', 'UserConfirmRegReminderHandler');
     $qm->connect('uinvrem', 'UserInviteReminderHandler');
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:14,代码来源:EmailReminderPlugin.php

示例2: handlePost

 /**
  * Handler for POST content updates from the hub
  */
 function handlePost()
 {
     $feedid = $this->arg('feed');
     common_log(LOG_INFO, "POST for feed id {$feedid}");
     if (!$feedid) {
         // TRANS: Server exception thrown when referring to a non-existing or empty feed.
         throw new ServerException(_m('Empty or invalid feed id.'), 400);
     }
     $feedsub = FeedSub::getKV('id', $feedid);
     if (!$feedsub instanceof FeedSub) {
         // TRANS: Server exception. %s is a feed ID.
         throw new ServerException(sprintf(_m('Unknown PuSH feed id %s'), $feedid), 400);
     }
     $hmac = '';
     if (isset($_SERVER['HTTP_X_HUB_SIGNATURE'])) {
         $hmac = $_SERVER['HTTP_X_HUB_SIGNATURE'];
     }
     $post = file_get_contents('php://input');
     // Queue this to a background process; we should return
     // as quickly as possible from a distribution POST.
     // If queues are disabled this'll process immediately.
     $data = array('feedsub_id' => $feedsub->id, 'post' => $post, 'hmac' => $hmac);
     $qm = QueueManager::get();
     $qm->enqueue($data, 'pushin');
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:28,代码来源:pushcallback.php

示例3: queueBackup

 function queueBackup()
 {
     $cur = common_current_user();
     $qm = QueueManager::get();
     $qm->enqueue($cur->id, 'backoff');
     $this->showPage();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:7,代码来源:offlinebackup.php

示例4: get

 static function get()
 {
     if (empty(self::$qm)) {
         if (Event::handle('StartNewQueueManager', array(&self::$qm))) {
             $enabled = common_config('queue', 'enabled');
             $type = common_config('queue', 'subsystem');
             if (!$enabled) {
                 // does everything immediately
                 self::$qm = new UnQueueManager();
             } else {
                 switch ($type) {
                     case 'db':
                         self::$qm = new DBQueueManager();
                         break;
                     case 'stomp':
                         self::$qm = new StompQueueManager();
                         break;
                     default:
                         throw new ServerException("No queue manager class for type '{$type}'");
                 }
             }
         }
     }
     return self::$qm;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:25,代码来源:queuemanager.php

示例5: initManagers

 /**
  * Initialize IoManagers for the currently configured site
  * which are appropriate to this instance.
  */
 function initManagers()
 {
     if (common_config('xmpp', 'enabled')) {
         $qm = QueueManager::get();
         $qm->setActiveGroup('xmpp');
         $this->instantiate($qm);
         $this->instantiate(XmppManager::get());
         $this->instantiate($this->processManager);
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:14,代码来源:xmppdaemon.php

示例6: doSendControl

function doSendControl($message, $event, $param = '')
{
    print $message;
    $qm = QueueManager::get();
    if ($qm->sendControlSignal($event, $param)) {
        print " sent.\n";
    } else {
        print " FAILED.\n";
    }
}
开发者ID:microcosmx,项目名称:experiments,代码行数:10,代码来源:queuectl.php

示例7: initManagers

 /**
  * Initialize IoManagers for the currently configured site
  * which are appropriate to this instance.
  */
 function initManagers()
 {
     $classes = array();
     if (Event::handle('StartImDaemonIoManagers', array(&$classes))) {
         $qm = QueueManager::get();
         $qm->setActiveGroup('im');
         $classes[] = $qm;
         $classes[] = $this->processManager;
     }
     Event::handle('EndImDaemonIoManagers', array(&$classes));
     foreach ($classes as $class) {
         $this->instantiate($class);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:18,代码来源:imdaemon.php

示例8: onEndInitializeQueueManager

 /**
  * Set up queue handlers for outgoing hub pushes
  * @param QueueManager $qm
  * @return boolean hook return
  */
 function onEndInitializeQueueManager(QueueManager $qm)
 {
     // Prepare outgoing distributions after notice save.
     $qm->connect('ostatus', 'OStatusQueueHandler');
     // Outgoing from our internal PuSH hub
     $qm->connect('hubconf', 'HubConfQueueHandler');
     $qm->connect('hubprep', 'HubPrepQueueHandler');
     $qm->connect('hubout', 'HubOutQueueHandler');
     // Outgoing Salmon replies (when we don't need a return value)
     $qm->connect('salmon', 'SalmonQueueHandler');
     // Incoming from a foreign PuSH hub
     $qm->connect('pushin', 'PushInQueueHandler');
     return true;
 }
开发者ID:Br3nda,项目名称:statusnet-debian,代码行数:19,代码来源:OStatusPlugin.php

示例9: handle

 public function handle($user)
 {
     if (!$user instanceof User) {
         common_log(LOG_ERR, "Got a bogus user, not deleting");
         return true;
     }
     $user = User::getKV('id', $user->id);
     if (!$user) {
         common_log(LOG_INFO, "User {$user->nickname} was deleted before we got here.");
         return true;
     }
     try {
         if (!$user->hasRole(Profile_role::DELETED)) {
             common_log(LOG_INFO, "User {$user->nickname} is not pending deletion; aborting.");
             return true;
         }
     } catch (UserNoProfileException $unp) {
         common_log(LOG_INFO, "Deleting user {$user->nickname} with no profile... probably a good idea!");
     }
     $notice = $this->getNextBatch($user);
     if ($notice->N) {
         common_log(LOG_INFO, "Deleting next {$notice->N} notices by {$user->nickname}");
         while ($notice->fetch()) {
             $del = clone $notice;
             $del->delete();
         }
         // @todo improve reliability in case we died during the above deletions
         // with a fatal error. If the job is lost, we should perform some kind
         // of garbage collection later.
         // Queue up the next batch.
         $qm = QueueManager::get();
         $qm->enqueue($user, 'deluser');
     } else {
         // Out of notices? Let's finish deleting this profile!
         try {
             $user->getProfile()->delete();
         } catch (UserNoProfileException $e) {
             // in case a profile didn't exist for some reason, just delete the User directly
             $user->delete();
         }
         common_log(LOG_INFO, "User {$user->id} {$user->nickname} deleted.");
         return true;
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:45,代码来源:deluserqueuehandler.php

示例10: handle

 /**
  * Handle the site
  *
  * @param array $remitem type of reminder to send and any special options
  * @return boolean true on success, false on failure
  */
 function handle($remitem)
 {
     list($type, $opts) = $remitem;
     $qm = QueueManager::get();
     try {
         switch ($type) {
             case UserConfirmRegReminderHandler::REGISTER_REMINDER:
                 $confirm = new Confirm_address();
                 $confirm->address_type = $type;
                 $confirm->find();
                 while ($confirm->fetch()) {
                     try {
                         $qm->enqueue(array($confirm, $opts), 'uregrem');
                     } catch (Exception $e) {
                         common_log(LOG_WARNING, $e->getMessage());
                         continue;
                     }
                 }
                 break;
             case UserInviteReminderHandler::INVITE_REMINDER:
                 $invitation = new Invitation();
                 // Only send one reminder (the latest one), regardless of how many invitations a user has
                 $sql = 'SELECT * FROM (SELECT * FROM invitation WHERE registered_user_id IS NULL ORDER BY created DESC) invitees GROUP BY invitees.address';
                 $invitation->query($sql);
                 while ($invitation->fetch()) {
                     try {
                         $qm->enqueue(array($invitation, $opts), 'uinvrem');
                     } catch (Exception $e) {
                         common_log(LOG_WARNING, $e->getMessage());
                         continue;
                     }
                 }
                 break;
             default:
                 // WTF?
                 common_log(LOG_ERR, "Received unknown confirmation address type", __FILE__);
         }
     } catch (Exception $e) {
         common_log(LOG_ERR, $e->getMessage());
         return false;
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:49,代码来源:siteconfirmreminderhandler.php

示例11: handle

 /**
  * Handle the site
  * 
  * @param mixed $object
  * @return boolean true on success, false on failure
  */
 function handle($object)
 {
     $qm = QueueManager::get();
     try {
         // Enqueue a summary for all users
         $user = new User();
         $user->find();
         while ($user->fetch()) {
             try {
                 $qm->enqueue($user->id, 'usersum');
             } catch (Exception $e) {
                 common_log(LOG_WARNING, $e->getMessage());
                 continue;
             }
         }
     } catch (Exception $e) {
         common_log(LOG_WARNING, $e->getMessage());
     }
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:26,代码来源:siteemailsummaryhandler.php

示例12: handle

 function handle($data)
 {
     list($user, $xml, $trusted) = $data;
     try {
         $doc = DOMDocument::loadXML($xml);
         $feed = $doc->documentElement;
         if ($feed->namespaceURI != Activity::ATOM || $feed->localName != 'feed') {
             // TRANS: Client exception thrown when an imported feed is not an Atom feed.
             throw new ClientException(_("Not an Atom feed."));
         }
         $author = ActivityUtils::getFeedAuthor($feed);
         if (empty($author)) {
             // TRANS: Client exception thrown when an imported feed does not have an author.
             throw new ClientException(_("No author in the feed."));
         }
         if (empty($user)) {
             if ($trusted) {
                 $user = $this->userFromAuthor($author);
             } else {
                 // TRANS: Client exception thrown when an imported feed does not have an author that
                 // TRANS: can be associated with a user.
                 throw new ClientException(_("Cannot import without a user."));
             }
         }
         $activities = $this->getActivities($feed);
         $qm = QueueManager::get();
         foreach ($activities as $activity) {
             $qm->enqueue(array($user, $author, $activity, $trusted), 'actimp');
         }
     } catch (ClientException $ce) {
         common_log(LOG_WARNING, $ce->getMessage());
         return true;
     } catch (ServerException $se) {
         common_log(LOG_ERR, $ce->getMessage());
         return false;
     } catch (Exception $e) {
         common_log(LOG_ERR, $ce->getMessage());
         return false;
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:40,代码来源:feedimporter.php

示例13: enqueueNewFeeds

 public static function enqueueNewFeeds(array $args = array())
 {
     if (!isset($args['interval']) || !is_int($args['interval']) || $args['interval'] <= 0) {
         $args['interval'] = self::DEFAULT_INTERVAL;
     }
     $args['interval'] *= 60;
     // minutes to seconds
     $feedsub = new FeedSub();
     $feedsub->sub_state = 'nohub';
     // Find feeds that haven't been polled within the desired interval,
     // though perhaps we're abusing the "last_update" field here?
     $feedsub->whereAdd(sprintf('last_update < "%s"', common_sql_date(time() - $args['interval'])));
     $feedsub->find();
     $qm = QueueManager::get();
     while ($feedsub->fetch()) {
         $orig = clone $feedsub;
         $item = array('id' => $feedsub->id);
         $qm->enqueue($item, self::QUEUE_CHECK);
         $feedsub->last_update = common_sql_now();
         $feedsub->update($orig);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:22,代码来源:feedpoll.php

示例14: handlePost

 /**
  * Handler for POST content updates from the hub
  */
 function handlePost()
 {
     $feedid = $this->arg('feed');
     common_log(LOG_INFO, "POST for feed id {$feedid}");
     if (!$feedid) {
         throw new ServerException('Empty or invalid feed id', 400);
     }
     $feedsub = FeedSub::staticGet('id', $feedid);
     if (!$feedsub) {
         throw new ServerException('Unknown PuSH feed id ' . $feedid, 400);
     }
     $hmac = '';
     if (isset($_SERVER['HTTP_X_HUB_SIGNATURE'])) {
         $hmac = $_SERVER['HTTP_X_HUB_SIGNATURE'];
     }
     $post = file_get_contents('php://input');
     // Queue this to a background process; we should return
     // as quickly as possible from a distribution POST.
     // If queues are disabled this'll process immediately.
     $data = array('feedsub_id' => $feedsub->id, 'post' => $post, 'hmac' => $hmac);
     $qm = QueueManager::get();
     $qm->enqueue($data, 'pushin');
 }
开发者ID:himmelex,项目名称:NTW,代码行数:26,代码来源:pushcallback.php

示例15: handle

 function handle($object)
 {
     list($user, $remote, $password) = $object;
     $remote = Discovery::normalize($remote);
     $oprofile = Ostatus_profile::ensureProfileURI($remote);
     if (empty($oprofile)) {
         // TRANS: Exception thrown when an account could not be located when it should be moved.
         // TRANS: %s is the remote site.
         throw new Exception(sprintf(_("Cannot locate account %s."), $remote));
     }
     list($svcDocUrl, $username) = self::getServiceDocument($remote);
     $sink = new ActivitySink($svcDocUrl, $username, $password);
     $this->log(LOG_INFO, "Moving user {$user->nickname} " . "to {$remote}.");
     $stream = new UserActivityStream($user);
     // Reverse activities to run in correct chron order
     $acts = array_reverse($stream->activities);
     $this->log(LOG_INFO, "Got " . count($acts) . " activities " . "for {$user->nickname}.");
     $qm = QueueManager::get();
     foreach ($acts as $act) {
         $qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove');
     }
     $this->log(LOG_INFO, "Finished moving user {$user->nickname} " . "to {$remote}.");
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:23,代码来源:accountmover.php


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