forked from whcyc2002/swoole_framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoa_client.php
More file actions
47 lines (44 loc) · 1.57 KB
/
soa_client.php
File metadata and controls
47 lines (44 loc) · 1.57 KB
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
<?php
define('DEBUG', 'on');
define('WEBPATH', dirname(__DIR__));
require __DIR__ . '/../libs/lib_config.php';
//require __DIR__ . '/../vendor/autoload.php';
$cloud = new Swoole\Client\SOA;
$cloud->addServers(array('127.0.0.1:8888'));
$s = microtime(true);
$ok = $err = 0;
for ($i = 0; $i < 1; $i++)
{
$s2 = microtime(true);
$ret1 = $cloud->task("BL\\Test::test1", "hello{$i}_1", function($retObj) {
echo "task1 finish\n";
});
$ret2 = $cloud->task("BL\\Test::hello");
$ret3 = $cloud->task("BL\\Test::test1", "hello{$i}_3");
$ret4 = $cloud->task("BL\\Test::test1", "hello{$i}_4");
$ret5 = $cloud->task("App\\Test::test1");
$ret6 = $cloud->task("BL\\Test::test1", "hello{$i}_6");
$ret7 = $cloud->task("BL\\Test::test1", "hello{$i}_7");
$ret8 = $cloud->task("BL\\Test::test1", "hello{$i}_8");
echo "send " . (microtime(true) - $s2) * 1000, "\n";
$n = $cloud->wait(0.5); //500ms超时
//表示全部OK了
if ($n === 8)
{
var_dump($ret1->data, $ret2->data, $ret3->data, $ret4->data, $ret5->data, $ret6->data, $ret7->data, $ret8->data);
echo "finish\n";
$ok++;
}
else
{
echo "#{$i} \t";
echo $ret1->code . '|' . $ret2->code . '|' . $ret3->code . '|' . $ret4->code . '|' . $ret5->code . '|' . $ret6->code . '|' . $ret7->code . '|' . $ret8->code . '|' . "\n";
$err++;
exit;
}
unset($ret1, $ret2, $ret3, $ret4, $ret5, $ret6, $ret7, $ret8);
}
echo "failed=$err.\n";
echo "success=$ok.\n";
echo "use " . (microtime(true) - $s) * 1000, "ms\n";
unset($cloud, $ret1, $ret2);