-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
92 lines (89 loc) · 2.63 KB
/
test.php
File metadata and controls
92 lines (89 loc) · 2.63 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Created by xcar.com.cn
* User: zng
* Date: 2017/4/1
* Time: 10:22
*/
require 'Seefan\ConsulClient.php';
$cc = new Seefan\ConsulClient(['host' => '10.15.203.113:8500']);
//var_dump( $cc->catalog->services());
//var_dump($cc->kv->get('service/0000'));
//var_dump($cc->agent->self());
//echo $cc->kv->set('test/test1', 'zng');
$cc->kv->delete('test/test1');
$str = '{
"ID": "redis1",
"Name": "scene",
"Tags": [
"primary",
"v1"
],
"Address": "127.0.0.1",
"Port": 8000,
"EnableTagOverride": false,
"Check": {
"DeregisterCriticalServiceAfter": "90m",
"HTTP": "http://localhost:5000/health",
"Interval": "10s",
"TTL": "10s"
}
}';
//$rsp=$cc->agent->service('deregister','redis1');
//$param = json_decode($str, true);
//$rsp = $cc->agent->put('service','register', $param);
//$rsp=$cc->catalog->header('service','XE');
//$rsp = $cc->catalog->service('XE', ['tag' => '0000']);
//$json_str = '{
// "Datacenter": "dc1",
// "ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
// "Node": "foobar",
// "Address": "192.168.10.10",
// "TaggedAddresses": {
// "lan": "192.168.10.10",
// "wan": "10.0.10.10"
// },
// "NodeMeta": {
// "somekey": "somevalue"
// },
// "Service": {
// "ID": "redis1",
// "Service": "redis",
// "Tags": [
// "primary",
// "v1"
// ],
// "Address": "127.0.0.1",
// "Port": 8000
// },
// "Check": {
// "Node": "foobar",
// "CheckID": "service:redis1",
// "Name": "Redis health check",
// "Notes": "Script based health check",
// "Status": "passing",
// "ServiceID": "redis1"
// }
// }';
//$json = json_decode($json_str, true);
//$rsp = $cc->catalog->register($json);
//$json_str='{
// "Datacenter": "dc1",
// "Node": "foobar"
//}';
//$json = json_decode($json_str, true);
//$rsp = $cc->catalog->deregister($json);
//$rsp=$cc->agent->checks();
//$param['recurse'] = true;
//$rsp = $cc->kv->get('config', $param);
$param['recurse'] = true;
$rsp = $cc->kv->get('user', $param);
if (is_array($rsp)) {
foreach ($rsp as $k => $v) {
$user[substr($k, 5)] = $v;
}
}
var_dump($user);
//$http = new Seefan\Http();
//$r=$http->header('10.20.28.51:8500/v1/kv/config', ['recurse' => true]);
//print_r($r);