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


PHP GearmanClient::doHighBackground方法代码示例

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


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

示例1: add

 public function add($hook, $args = array(), $priority = 'normal')
 {
     $jobdata = array();
     $jobdata['hook'] = $hook;
     $jobdata['args'] = $args;
     $jobdata['blog_id'] = function_exists('is_multisite') && is_multisite() ? get_current_blog_id() : null;
     switch ($priority) {
         case 'high':
             return $this->_client->doHighBackground($this->gearman_function(), json_encode($jobdata));
             break;
         case 'low':
             return $this->_client->doLowBackground($this->gearman_function(), json_encode($jobdata));
             break;
         case 'normal':
         default:
             return $this->_client->doBackground($this->gearman_function(), json_encode($jobdata));
             break;
     }
 }
开发者ID:10up,项目名称:wp-gears,代码行数:19,代码来源:class-gearman-async-task.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /* @var $em EntityManager */
     $em = $this->getContainer()->get('doctrine')->getManager();
     $waktuSekarang = new \DateTime();
     $perulangan = JadwalKehadiran::getDaftarPerulangan();
     $workload['waktu_sekarang'] = $waktuSekarang;
     $workload['paksa'] = $input->getOption('paksa');
     $semuaSekolah = $em->getRepository('LanggasSisdikBundle:Sekolah')->findAll();
     foreach ($semuaSekolah as $sekolah) {
         if (!(is_object($sekolah) && $sekolah instanceof Sekolah)) {
             continue;
         }
         $workload['sekolah'] = $sekolah->getId();
         if (!$input->getOption('paksa')) {
             $kalenderPendidikan = $em->getRepository('LanggasSisdikBundle:KalenderPendidikan')->findOneBy(['sekolah' => $sekolah, 'tanggal' => $waktuSekarang, 'kbm' => true]);
             if (!(is_object($kalenderPendidikan) && $kalenderPendidikan instanceof KalenderPendidikan)) {
                 continue;
             }
         }
         $mesinKehadiran = $em->getRepository('LanggasSisdikBundle:MesinKehadiran')->findBy(['sekolah' => $sekolah, 'aktif' => true]);
         foreach ($perulangan as $key => $value) {
             $workload['perulangan'] = $key;
             $logDirectory = $this->getContainer()->get('kernel')->getRootDir() . DIRECTORY_SEPARATOR . 'fingerprintlogs' . DIRECTORY_SEPARATOR . $sekolah->getId() . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . $key . DIRECTORY_SEPARATOR . $waktuSekarang->format('Y-m-d');
             if (!is_dir($logDirectory)) {
                 continue;
             }
             foreach ($mesinKehadiran as $mesin) {
                 if (!(is_object($mesin) && $mesin instanceof MesinKehadiran)) {
                     continue;
                 }
                 if ($mesin->getAlamatIp() == '') {
                     continue;
                 }
                 $logFiles = [];
                 exec("cd {$logDirectory} && ls -1t {$mesin->getAlamatIp()}*", $logFiles);
                 $logFile = '';
                 foreach ($logFiles as $logFile) {
                     if ($logFile == '') {
                         continue;
                     }
                     if (!$input->getOption('paksa')) {
                         $prosesLog = $em->createQueryBuilder()->select('COUNT(prosesLog.id)')->from('LanggasSisdikBundle:ProsesLogKehadiran', 'prosesLog')->where('prosesLog.sekolah = :sekolah')->andWhere('prosesLog.namaFile = :namaFile')->setParameter('sekolah', $sekolah)->setParameter('namaFile', $logFile)->getQuery()->getSingleScalarResult();
                         if ($prosesLog > 0) {
                             continue;
                         }
                     }
                     $workload['log_file'] = $logDirectory . DIRECTORY_SEPARATOR . $logFile;
                     /* @var $logger Logger */
                     $logger = $this->getContainer()->get('monolog.logger.attendance');
                     $gearman = new \GearmanClient();
                     $gearman->addServer();
                     $jobFunction = "LanggasSisdikBundleWorkerPembaruanKehadiranWorker~pembaruan";
                     $proses = new ProsesLogKehadiran();
                     $proses->setAwalProses($waktuSekarang);
                     $proses->setNamaFile($logFile);
                     $proses->setSekolah($sekolah);
                     $proses->setStatusAntrian('a-masuk-antrian');
                     $proses->setPrioritas($input->getOption('prioritas'));
                     $em->persist($proses);
                     $em->flush();
                     $workload['proses_log'] = $proses->getId();
                     switch ($input->getOption('prioritas')) {
                         case "tinggi":
                             $gearman->doHighBackground($jobFunction, serialize($workload));
                             $logger->addInfo($sekolah->getId() . ' | ' . $sekolah->getNama() . ' | kehadiran | prioritas-tinggi | ' . $workload['log_file']);
                             break;
                         case "normal":
                             $gearman->doBackground($jobFunction, serialize($workload));
                             $logger->addInfo($sekolah->getId() . ' | ' . $sekolah->getNama() . ' | kehadiran | prioritas-normal | ' . $workload['log_file']);
                             break;
                         case "rendah":
                             $gearman->doLowBackground($jobFunction, serialize($workload));
                             $logger->addInfo($sekolah->getId() . ' | ' . $sekolah->getNama() . ' | kehadiran | prioritas-rendah | ' . $workload['log_file']);
                             break;
                     }
                 }
             }
         }
     }
 }
开发者ID:alisyihab,项目名称:sisdik,代码行数:81,代码来源:PembaruanKehadiranCommand.php

示例3: doHighBackground

 public function doHighBackground($task, $data)
 {
     return $this->_gearmanClient->doHighBackground($task, $data);
 }
开发者ID:otis22,项目名称:reserve-copy-system,代码行数:4,代码来源:JobServer.php

示例4: function

 *
 * We'll use the same script as both the client and the worker for
 * convenience.
 */
// Create our worker
$worker = new \GearmanWorker();
$worker->addServer('192.168.133.72', 4730);
// Create our client
$client = new \GearmanClient();
$client->addServer('192.168.133.72', 4730);
// Service "foo" jobs by displaying "foo"
$worker->addFunction('foo', function (\GearmanJob $job) {
    echo "foo\n";
});
// Service "bar" jobs by displaying "bar"
$worker->addFunction('bar', function (\GearmanJob $job) {
    echo "bar\n";
});
// Add 25 LOW priority "foo" jobs to the queue.
for ($i = 0; $i < 25; $i++) {
    $client->doLowBackground('foo', '{}');
}
// Add 1 HIGH priority "bar" job to the queue.
$client->doHighBackground('bar', '{}');
/**
 * Running ->work() will service the pending jobs.
 *
 * What would you expect the output order to be?
 */
while ($worker->work()) {
}
开发者ID:michaelmoussa,项目名称:talks,代码行数:31,代码来源:priority-1.php

示例5: function

/**
 * This script demonstrates how to work around Gearman's unintuitive behavior
 * when it comes to servicing jobs of different priorities.
 *
 * We'll use the same script as both the client and the worker for
 * convenience.
 */
// Create our worker
$worker = new \GearmanWorker();
$worker->addServer('192.168.133.72', 4730);
// Create our client
$client = new \GearmanClient();
$client->addServer('192.168.133.72', 4730);
// Use the same "Function" (i.e. queue) name and distinguish jobs by workload.
$worker->addFunction('foobar', function (\GearmanJob $job) {
    $workload = json_decode($job->workload(), true);
    echo $workload['function'] . "\n";
});
// Add 25 LOW priority "foo" jobs to the queue.
for ($i = 0; $i < 25; $i++) {
    $client->doLowBackground('foobar', '{"function": "foo"}');
}
// Add 1 HIGH priority "bar" job to the queue.
$client->doHighBackground('foobar', '{"function": "bar"}');
/**
 * Running ->work() will service the pending jobs.
 *
 * Notice how the HIGH priority job is serviced *FIRST* this time.
 */
while ($worker->work()) {
}
开发者ID:michaelmoussa,项目名称:talks,代码行数:31,代码来源:priority-2.php

示例6: doHighBackground

 public function doHighBackground($function_name, $workload, $unique = null)
 {
     $function_name = $this->_processFunctionName($function_name);
     return parent::doHighBackground($function_name, $workload, $unique);
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:5,代码来源:Client.php

示例7: changeTheme

 function changeTheme($data)
 {
     // Validate id
     $id = (int) $data['template'];
     $username = $_SESSION['gh']['username'];
     $r = $this->db->query("select * from templates where id='{$id}'");
     if ($r->num_rows < 1) {
         $_SESSION['error'] = 'Invalid template selected.';
         return false;
     }
     $row = $r->fetch_array(MYSQLI_ASSOC);
     $workload = json_encode(array('token' => $this->access_token, 'email' => $_SESSION['gh']['email'], 'template_id' => $id, 'template_path' => $row['path'], 'repo' => $username . '.github.io', 'user_id' => $_SESSION['gh']['id'], 'username' => $username, 'post_data' => $data));
     $client = new GearmanClient();
     $client->addServer();
     $client->doHighBackground("change_theme", $workload);
     return true;
 }
开发者ID:kehers,项目名称:tinypress,代码行数:17,代码来源:App.php


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