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


PHP Connection::send方法代码示例

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


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

示例1: send

 /**
  * actually sends a message to to the daemon and returns the sent message
  *
  * @param string $key
  * @param int $value
  * @param string $type
  * @param int $sampleRate
  */
 private function send($key, $value, $type, $sampleRate)
 {
     if (strlen($this->namespace) != 0) {
         $key = sprintf('%s.%s', $this->namespace, $key);
     }
     $message = sprintf("%s:%s|%s", $key, $value, $type);
     $sample = mt_rand() / mt_getrandmax();
     if ($sample > $sampleRate) {
         return;
     }
     // overwrite sampleRate if all metrics should be sampled
     if ($this->sampleRateAllMetrics < 1) {
         $sampleRate = $this->sampleRateAllMetrics;
     }
     if ($sampleRate < 1) {
         $sampledData = sprintf('%s|@%s', $message, $sampleRate);
     } else {
         $sampledData = $message;
     }
     if (!$this->isBatch) {
         $this->connection->send($sampledData);
     } else {
         $this->batch[] = $sampledData;
     }
 }
开发者ID:mike-marcacci,项目名称:statsd-php,代码行数:33,代码来源:Client.php

示例2: truncate

 /**
  * @param string $_table
  */
 public function truncate($_table)
 {
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('truncate: ' . $_table);
     }
     if (empty($_table)) {
         throw new UndefinedTabelException('null');
     }
     $table = $this->connection->escape($_table);
     $sql = 'TRUNCATE TABLE `' . $table . '`';
     $result = $this->connection->send($sql);
 }
开发者ID:keil,项目名称:phpDBI-MySQL-Database-Interface-,代码行数:16,代码来源:Database.class.php

示例3: delete

 /**
  * @param string $_index
  */
 public function delete($_index)
 {
     /* ## LOGGER ## */
     if (isset($this->logger)) {
         $this->logger->DEBUG('delete');
     }
     if (empty($_index)) {
         throw new UndefinedRowException('null');
     }
     $table = $this->connection->escape($this->table);
     $primary = $this->connection->escape($this->primary);
     $index = $this->connection->escape($_index);
     $sql = 'DELETE FROM `' . $table . '` WHERE `' . $primary . '` = \'' . $index . '\';';
     $result = $this->connection->send($sql);
     if ($this->connection->getAffectedRows() <= 0) {
         throw new UndefinedRowException('undefined ' . $primary . '=' . $index);
     }
 }
开发者ID:keil,项目名称:phpDBI-MySQL-Database-Interface-,代码行数:21,代码来源:Table.class.php

示例4: jobFail

 /**
  * Mark your job as failing
  *
  * If your job fails for some reason (e.g. a query fails) you need to run
  * this function and exit from your run() method. This will tell Gearman
  * (and the client by proxy) that the job has failed.
  *
  * @param resource $socket
  * @param string $handle
  *
  * @see Net\Gearman\Connection::send()
  */
 private function jobFail($socket, $handle)
 {
     Connection::send($socket, 'work_fail', array('handle' => $handle));
 }
开发者ID:elvis-bi,项目名称:net_gearman,代码行数:16,代码来源:Worker.php

示例5: endBatch

 /**
  * ends batch-send-recording and sends the recorded messages to the connection
  *
  * @return void
  */
 public function endBatch()
 {
     $this->_isBatch = false;
     $this->_connection->send(join("\n", $this->_batch));
     $this->_batch = array();
 }
开发者ID:M-R-K-Development,项目名称:wordpress-statsd,代码行数:11,代码来源:statsd.php

示例6: submitTask

 /**
  * Submit a task to Gearman
  *
  * @param Task $task Task to submit to Gearman
  *
  * @return      void
  * @see         \Net\Gearman\Task, \Net\Gearman\Client::runSet()
  */
 protected function submitTask(Task $task)
 {
     switch ($task->type) {
         case Task::JOB_LOW:
             $type = 'submit_job_low';
             break;
         case Task::JOB_LOW_BACKGROUND:
             $type = 'submit_job_low_bg';
             break;
         case Task::JOB_HIGH_BACKGROUND:
             $type = 'submit_job_high_bg';
             break;
         case Task::JOB_BACKGROUND:
             $type = 'submit_job_bg';
             break;
         case Task::JOB_EPOCH:
             $type = 'submit_job_epoch';
             break;
         case Task::JOB_HIGH:
             $type = 'submit_job_high';
             break;
         default:
             $type = 'submit_job';
             break;
     }
     $arg = $task->arg;
     $params = array('func' => $task->func, 'uniq' => $task->uniq, 'arg' => $arg);
     if ($task->type == Task::JOB_EPOCH) {
         $params['epoch'] = $task->epoch;
     }
     $s = $this->getConnection();
     Connection::send($s, $type, $params);
     if (!is_array(Connection::$waiting[(int) $s])) {
         Connection::$waiting[(int) $s] = array();
     }
     array_push(Connection::$waiting[(int) $s], $task);
 }
开发者ID:eyefi,项目名称:net_gearman,代码行数:45,代码来源:Client.php


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