ModelsConcurrent.php
980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Created by PhpStorm.
* User: Zip
* Date: 14/11/27
* Time: 下午1:10
*/
namespace LibModels;
use Hood\Concurrent as hoodConcurrent;
class ModelsConcurrent
{
static protected $uri = 'http://service.example.yohobuy.com/service/product/v1';
/**
* @var Concurrent|Concurrent\Yar\Concurrent
*/
static private $concurrent;
/**
* @return Concurrent|Concurrent\Yar\Concurrent
*/
static protected function connect()
{
if (empty(self::$concurrent)) {
self::$concurrent = hoodConcurrent::yarConcurrent(self::$uri);
}
return self::$concurrent;
}
static public function loop()
{
self::connect()->loop('Models\ModelsConcurrent::callback', 'Models\ModelsConcurrent::errorCallback');
}
static public function errorCallback($type, $error, $callinfo)
{
print_r($error);
}
static public function callback($ret, $callinfo)
{
}
}