pubo-node 1.0.156 → 1.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pubo-node.js +1 -1
- package/es/child-process/index.js +129 -362
- package/es/file-system/index.js +25 -32
- package/es/ftp-client/index.js +120 -245
- package/es/grpc/index.js +92 -158
- package/es/index.d.ts +1 -1
- package/es/index.js +3 -3
- package/es/ros/topic.js +70 -113
- package/es/storage/json.js +147 -296
- package/es/utils/index.js +13 -13
- package/es/utils/network.js +30 -53
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -3
- package/package.json +3 -3
package/es/ftp-client/index.js
CHANGED
|
@@ -1,260 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function _invoke(body, then) {
|
|
13
|
-
var result = body();
|
|
14
|
-
if (result && result.then) {
|
|
15
|
-
return result.then(then);
|
|
16
|
-
}
|
|
17
|
-
return then(result);
|
|
18
|
-
}
|
|
19
|
-
function _empty() {}
|
|
20
|
-
function _awaitIgnored(value, direct) {
|
|
21
|
-
if (!direct) {
|
|
22
|
-
return value && value.then ? value.then(_empty) : Promise.resolve();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function _async(f) {
|
|
26
|
-
return function () {
|
|
27
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
28
|
-
args[i] = arguments[i];
|
|
1
|
+
import { random, waitFor } from 'pubo-utils';
|
|
2
|
+
export class FtpClient {
|
|
3
|
+
driver;
|
|
4
|
+
options;
|
|
5
|
+
state = { running: false, connected: false, destroyed: false, connecting: false };
|
|
6
|
+
client;
|
|
7
|
+
_len = 0;
|
|
8
|
+
id = random();
|
|
9
|
+
constructor({ driver, ...options }) {
|
|
10
|
+
this.driver = driver;
|
|
11
|
+
this.options = options;
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} catch (e) {
|
|
33
|
-
return Promise.reject(e);
|
|
13
|
+
get len() {
|
|
14
|
+
return this._len;
|
|
34
15
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
connected: false,
|
|
53
|
-
destroyed: false,
|
|
54
|
-
connecting: false
|
|
55
|
-
};
|
|
56
|
-
this.client = void 0;
|
|
57
|
-
this._len = 0;
|
|
58
|
-
this.id = random();
|
|
59
|
-
this.put = this.bind('put');
|
|
60
|
-
this["delete"] = this.bind('delete');
|
|
61
|
-
this.list = this.bind('list');
|
|
62
|
-
this.rename = this.bind('rename');
|
|
63
|
-
this.driver = driver;
|
|
64
|
-
this.options = options;
|
|
65
|
-
}
|
|
66
|
-
var _proto = FtpClient.prototype;
|
|
67
|
-
_proto.connect = function connect() {
|
|
68
|
-
try {
|
|
69
|
-
var _exit = false;
|
|
70
|
-
var _this = this;
|
|
71
|
-
if (!_this.client) {
|
|
72
|
-
_this.client = new _this.driver();
|
|
73
|
-
}
|
|
74
|
-
_this.state.destroyed = false;
|
|
75
|
-
return _await(_invoke(function () {
|
|
76
|
-
if (_this.state.connecting) {
|
|
77
|
-
return _await(waitFor(function () {
|
|
78
|
-
return _this.state.connected;
|
|
79
|
-
}, {
|
|
80
|
-
checkTime: 1000,
|
|
81
|
-
timeout: 10000
|
|
82
|
-
}), function () {
|
|
83
|
-
_exit = true;
|
|
16
|
+
set len(n) {
|
|
17
|
+
this._len = n;
|
|
18
|
+
if (this._len < 1) {
|
|
19
|
+
this.close();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
put = this.bind('put');
|
|
23
|
+
delete = this.bind('delete');
|
|
24
|
+
list = this.bind('list');
|
|
25
|
+
rename = this.bind('rename');
|
|
26
|
+
async connect() {
|
|
27
|
+
if (!this.client) {
|
|
28
|
+
this.client = new this.driver();
|
|
29
|
+
}
|
|
30
|
+
this.state.destroyed = false;
|
|
31
|
+
if (this.state.connecting) {
|
|
32
|
+
await waitFor(() => this.state.connected, { checkTime: 1000, timeout: 10000 });
|
|
84
33
|
return 'connected';
|
|
85
|
-
});
|
|
86
34
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
100
|
-
_this.client.connect(_extends({}, _this.options));
|
|
35
|
+
this.state.connecting = true;
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
this.client.once('ready', () => {
|
|
38
|
+
this.state.connected = true;
|
|
39
|
+
resolve('connected');
|
|
40
|
+
this.state.connecting = false;
|
|
41
|
+
});
|
|
42
|
+
this.client.once('error', (err) => {
|
|
43
|
+
reject(err);
|
|
44
|
+
this.close();
|
|
45
|
+
});
|
|
46
|
+
this.client.connect({ ...this.options });
|
|
101
47
|
});
|
|
102
|
-
}));
|
|
103
|
-
} catch (e) {
|
|
104
|
-
return Promise.reject(e);
|
|
105
48
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
var _this2 = this;
|
|
119
|
-
_this2.len += 1;
|
|
120
|
-
return _await(_invoke(function () {
|
|
121
|
-
if (!_this2.state.connected) {
|
|
122
|
-
return _awaitIgnored(_this2.connect());
|
|
49
|
+
close() {
|
|
50
|
+
this.client.end();
|
|
51
|
+
this.state.connected = false;
|
|
52
|
+
this.state.destroyed = true;
|
|
53
|
+
this.state.connecting = false;
|
|
54
|
+
this.client = null;
|
|
55
|
+
}
|
|
56
|
+
async run({ fn, args }) {
|
|
57
|
+
this.len += 1;
|
|
58
|
+
if (!this.state.connected) {
|
|
59
|
+
await this.connect();
|
|
123
60
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
var _this2$client;
|
|
138
|
-
(_this2$client = _this2.client)[fn].apply(_this2$client, args.concat([function (err, res) {
|
|
139
|
-
if (err) {
|
|
140
|
-
reject(err);
|
|
141
|
-
} else {
|
|
142
|
-
resolve(res);
|
|
143
|
-
}
|
|
144
|
-
}]));
|
|
145
|
-
});
|
|
61
|
+
if (this.state.running) {
|
|
62
|
+
await waitFor(() => !this.state.running, { checkTime: 1000, timeout: 6000000 });
|
|
63
|
+
}
|
|
64
|
+
this.state.running = true;
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
this.client[fn](...args, (err, res) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
reject(err);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
resolve(res);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
146
74
|
});
|
|
147
|
-
}));
|
|
148
|
-
} catch (e) {
|
|
149
|
-
return Promise.reject(e);
|
|
150
75
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
var res = Buffer.alloc(0);
|
|
172
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
173
|
-
args[_key2] = arguments[_key2];
|
|
174
|
-
}
|
|
175
|
-
return _await(_this4.run({
|
|
176
|
-
fn: 'get',
|
|
177
|
-
args: args
|
|
178
|
-
}), function (stream) {
|
|
179
|
-
return new Promise(function (resolve) {
|
|
180
|
-
stream.on('data', function (chunk) {
|
|
181
|
-
res = Buffer.concat([res, chunk], res.byteLength + chunk.byteLength);
|
|
182
|
-
});
|
|
183
|
-
stream.on('end', function () {
|
|
184
|
-
resolve(res);
|
|
185
|
-
_this4.state.running = false;
|
|
186
|
-
_this4.len -= 1;
|
|
187
|
-
});
|
|
76
|
+
bind(fn) {
|
|
77
|
+
return async (...args) => {
|
|
78
|
+
const res = await this.run({ fn, args });
|
|
79
|
+
this.state.running = false;
|
|
80
|
+
this.len -= 1;
|
|
81
|
+
return res;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async get(...args) {
|
|
85
|
+
let res = Buffer.alloc(0);
|
|
86
|
+
const stream = await this.run({ fn: 'get', args });
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
stream.on('data', (chunk) => {
|
|
89
|
+
res = Buffer.concat([res, chunk], res.byteLength + chunk.byteLength);
|
|
90
|
+
});
|
|
91
|
+
stream.on('end', () => {
|
|
92
|
+
resolve(res);
|
|
93
|
+
this.state.running = false;
|
|
94
|
+
this.len -= 1;
|
|
95
|
+
});
|
|
188
96
|
});
|
|
189
|
-
});
|
|
190
|
-
} catch (e) {
|
|
191
|
-
return Promise.reject(e);
|
|
192
97
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
98
|
+
}
|
|
99
|
+
export class FtpClientPool {
|
|
100
|
+
options;
|
|
101
|
+
maxConnection;
|
|
102
|
+
pool = [];
|
|
103
|
+
constructor({ maxConnection = 5, ...options }) {
|
|
104
|
+
this.options = options;
|
|
105
|
+
this.maxConnection = maxConnection;
|
|
106
|
+
}
|
|
107
|
+
get = this.bind('get');
|
|
108
|
+
put = this.bind('put');
|
|
109
|
+
delete = this.bind('delete');
|
|
110
|
+
list = this.bind('list');
|
|
111
|
+
rename = this.bind('rename');
|
|
112
|
+
get len() {
|
|
113
|
+
return this.pool.length;
|
|
204
114
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
var _ref3$maxConnection = _ref3.maxConnection,
|
|
211
|
-
maxConnection = _ref3$maxConnection === void 0 ? 5 : _ref3$maxConnection,
|
|
212
|
-
options = _objectWithoutPropertiesLoose(_ref3, _excluded2);
|
|
213
|
-
this.options = void 0;
|
|
214
|
-
this.maxConnection = void 0;
|
|
215
|
-
this.pool = [];
|
|
216
|
-
this.get = this.bind('get');
|
|
217
|
-
this.put = this.bind('put');
|
|
218
|
-
this["delete"] = this.bind('delete');
|
|
219
|
-
this.list = this.bind('list');
|
|
220
|
-
this.rename = this.bind('rename');
|
|
221
|
-
this.options = options;
|
|
222
|
-
this.maxConnection = maxConnection;
|
|
223
|
-
}
|
|
224
|
-
var _proto2 = FtpClientPool.prototype;
|
|
225
|
-
_proto2.bind = function bind(fn) {
|
|
226
|
-
var _this5 = this;
|
|
227
|
-
return _async(function () {
|
|
228
|
-
var client = _this5.client;
|
|
229
|
-
return _await(client[fn].apply(client, arguments), function (res) {
|
|
230
|
-
if (client.len < 1) {
|
|
231
|
-
var index = _this5.pool.findIndex(function (item) {
|
|
232
|
-
return item.id === client.id;
|
|
233
|
-
});
|
|
234
|
-
_this5.pool.splice(index, 1);
|
|
115
|
+
get client() {
|
|
116
|
+
if (this.pool.length < this.maxConnection) {
|
|
117
|
+
const client = new FtpClient(this.options);
|
|
118
|
+
this.pool.push(client);
|
|
119
|
+
return client;
|
|
235
120
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
_createClass(FtpClientPool, [{
|
|
241
|
-
key: "len",
|
|
242
|
-
get: function get() {
|
|
243
|
-
return this.pool.length;
|
|
121
|
+
this.pool.sort((a, b) => a.len - b.len);
|
|
122
|
+
return this.pool[0];
|
|
244
123
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
return this.pool[0];
|
|
124
|
+
bind(fn) {
|
|
125
|
+
return async (...args) => {
|
|
126
|
+
const client = this.client;
|
|
127
|
+
const res = await client[fn](...args);
|
|
128
|
+
if (client.len < 1) {
|
|
129
|
+
const index = this.pool.findIndex((item) => item.id === client.id);
|
|
130
|
+
this.pool.splice(index, 1);
|
|
131
|
+
}
|
|
132
|
+
return res;
|
|
133
|
+
};
|
|
257
134
|
}
|
|
258
|
-
|
|
259
|
-
return FtpClientPool;
|
|
260
|
-
}();
|
|
135
|
+
}
|
package/es/grpc/index.js
CHANGED
|
@@ -1,169 +1,103 @@
|
|
|
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
|
-
this.credentials = void 0;
|
|
40
|
-
this.client = void 0;
|
|
41
|
-
this._timeout = void 0;
|
|
42
|
-
this.connections = 0;
|
|
43
|
-
var opt = _extends({
|
|
44
|
-
'grpc.max_send_message_length': -1,
|
|
45
|
-
'grpc.max_receive_message_length': -1
|
|
46
|
-
}, options);
|
|
47
|
-
var credentials = cert ? Grpc.credentials.createSsl(cert) : Grpc.credentials.createInsecure();
|
|
48
|
-
this.url = url;
|
|
49
|
-
this.Grpc = Grpc;
|
|
50
|
-
this.credentials = credentials;
|
|
51
|
-
this.options = opt;
|
|
52
|
-
this.options.timeout = (_this$options$timeout = this.options.timeout) != null ? _this$options$timeout : 10000;
|
|
53
|
-
Grpc = null;
|
|
54
|
-
options = null;
|
|
55
|
-
cert = null;
|
|
56
|
-
}
|
|
57
|
-
var _proto = GrpcClient.prototype;
|
|
58
|
-
_proto.request = function request(service, method, data) {
|
|
59
|
-
try {
|
|
60
|
-
var _this = this;
|
|
61
|
-
if (_this._timeout) {
|
|
62
|
-
clearTimeout(_this._timeout);
|
|
63
|
-
_this._timeout = null;
|
|
64
|
-
}
|
|
65
|
-
_this.connections += 1;
|
|
66
|
-
if (!_this.client) {
|
|
67
|
-
_this.client = new _this.Grpc.Client(_this.url, _this.credentials, _this.options);
|
|
68
|
-
}
|
|
69
|
-
var error;
|
|
70
|
-
var result = Buffer.alloc(0);
|
|
71
|
-
return _await(_continue(_catch(function () {
|
|
72
|
-
return _await(_this._request({
|
|
73
|
-
service: service,
|
|
74
|
-
method: method,
|
|
75
|
-
data: data
|
|
76
|
-
}), function (_this$_request) {
|
|
77
|
-
result = _this$_request;
|
|
78
|
-
});
|
|
79
|
-
}, function (err) {
|
|
80
|
-
error = err;
|
|
81
|
-
}), function () {
|
|
1
|
+
const passThrough = (argument) => argument;
|
|
2
|
+
class GrpcClient {
|
|
3
|
+
url;
|
|
4
|
+
options;
|
|
5
|
+
Grpc;
|
|
6
|
+
credentials;
|
|
7
|
+
client;
|
|
8
|
+
_timeout;
|
|
9
|
+
connections = 0;
|
|
10
|
+
constructor({ url, options = {}, Grpc, cert }) {
|
|
11
|
+
const opt = { 'grpc.max_send_message_length': -1, 'grpc.max_receive_message_length': -1, ...options };
|
|
12
|
+
const credentials = cert ? Grpc.credentials.createSsl(cert) : Grpc.credentials.createInsecure();
|
|
13
|
+
this.url = url;
|
|
14
|
+
this.Grpc = Grpc;
|
|
15
|
+
this.credentials = credentials;
|
|
16
|
+
this.options = opt;
|
|
17
|
+
this.options.timeout = this.options.timeout ?? 10000;
|
|
18
|
+
Grpc = null;
|
|
19
|
+
options = null;
|
|
20
|
+
cert = null;
|
|
21
|
+
}
|
|
22
|
+
async request(service, method, data) {
|
|
23
|
+
if (this._timeout) {
|
|
24
|
+
clearTimeout(this._timeout);
|
|
25
|
+
this._timeout = null;
|
|
26
|
+
}
|
|
27
|
+
this.connections += 1;
|
|
28
|
+
if (!this.client) {
|
|
29
|
+
this.client = new this.Grpc.Client(this.url, this.credentials, this.options);
|
|
30
|
+
}
|
|
31
|
+
let error;
|
|
32
|
+
let result = Buffer.alloc(0);
|
|
33
|
+
try {
|
|
34
|
+
result = await this._request({ service, method, data });
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
error = err;
|
|
38
|
+
}
|
|
82
39
|
service = null;
|
|
83
40
|
method = null;
|
|
84
41
|
data = null;
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
42
|
+
this.connections -= 1;
|
|
43
|
+
if (this.connections < 0) {
|
|
44
|
+
this.connections = 0;
|
|
88
45
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return _this.close();
|
|
96
|
-
}, 60000);
|
|
46
|
+
if (this.connections < 1) {
|
|
47
|
+
if (this._timeout) {
|
|
48
|
+
clearTimeout(this._timeout);
|
|
49
|
+
this._timeout = null;
|
|
50
|
+
}
|
|
51
|
+
this._timeout = setTimeout(() => this.close(), 60000);
|
|
97
52
|
}
|
|
98
53
|
if (error) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
54
|
+
console.log(error);
|
|
55
|
+
this.close();
|
|
56
|
+
throw new Error('grpc connection error.');
|
|
102
57
|
}
|
|
103
58
|
return result;
|
|
104
|
-
}));
|
|
105
|
-
} catch (e) {
|
|
106
|
-
return Promise.reject(e);
|
|
107
59
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
60
|
+
_request({ service, method, data }) {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
let _ended = false;
|
|
63
|
+
const _timeout = setTimeout(() => {
|
|
64
|
+
_ended = true;
|
|
65
|
+
this.close();
|
|
66
|
+
console.log('rpc request timeout');
|
|
67
|
+
reject(new Error('timeout'));
|
|
68
|
+
}, this.options.timeout);
|
|
69
|
+
const onResponse = (err, res) => {
|
|
70
|
+
if (_ended) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
clearTimeout(_timeout);
|
|
75
|
+
}
|
|
76
|
+
if (err) {
|
|
77
|
+
reject(err);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
resolve(res);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
this.client.makeUnaryRequest(`/${service}/${method}`, passThrough, passThrough, data ? Buffer.from(data) : Buffer.alloc(0), onResponse);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
close() {
|
|
87
|
+
if (this._timeout) {
|
|
88
|
+
clearTimeout(this._timeout);
|
|
89
|
+
delete this._timeout;
|
|
132
90
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
137
|
-
_proto.close = function close() {
|
|
138
|
-
var _this$client;
|
|
139
|
-
if (this._timeout) {
|
|
140
|
-
clearTimeout(this._timeout);
|
|
141
|
-
delete this._timeout;
|
|
91
|
+
this.client?.close();
|
|
92
|
+
this.client = null;
|
|
93
|
+
delete this.client;
|
|
142
94
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
_ref3$options = _ref3.options,
|
|
153
|
-
options = _ref3$options === void 0 ? {} : _ref3$options,
|
|
154
|
-
ServiceImp = _ref3.ServiceImp,
|
|
155
|
-
Grpc = _ref3.Grpc,
|
|
156
|
-
cert = _ref3.cert;
|
|
157
|
-
var client = new GrpcClient({
|
|
158
|
-
url: url,
|
|
159
|
-
options: options,
|
|
160
|
-
Grpc: Grpc,
|
|
161
|
-
cert: cert
|
|
162
|
-
});
|
|
163
|
-
GrpcList.push(client);
|
|
164
|
-
Grpc = null;
|
|
165
|
-
options = null;
|
|
166
|
-
return new ServiceImp({
|
|
167
|
-
request: client.request.bind(client)
|
|
168
|
-
});
|
|
169
|
-
}
|
|
95
|
+
}
|
|
96
|
+
export const GrpcList = [];
|
|
97
|
+
export function createRpcClient({ url, options = {}, ServiceImp, Grpc, cert }) {
|
|
98
|
+
const client = new GrpcClient({ url, options, Grpc, cert });
|
|
99
|
+
GrpcList.push(client);
|
|
100
|
+
Grpc = null;
|
|
101
|
+
options = null;
|
|
102
|
+
return new ServiceImp({ request: client.request.bind(client) });
|
|
103
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { JsonStorage } from './storage/json';
|
|
2
2
|
export { FtpClient, FtpClientPool, FtpConnectOptions, FtpFile } from './ftp-client';
|
|
3
3
|
export { createRpcClient, GrpcList } from './grpc';
|
|
4
|
-
export { PuboFileSystem } from './file-system';
|
|
5
4
|
export { SIGKILL, isProcessDied, getProcessName, getProcessTree, getProcessByPpid, getProcessCpuUseByPid, getProcessCommandByPid, heartbeat, } from './child-process';
|
|
6
5
|
export { isPortAvailable } from './utils';
|
|
7
6
|
export { getWifiName, getNetworks } from './utils/network';
|
|
8
7
|
export { RosTopicManager, RosTopic } from './ros/topic';
|
|
8
|
+
export { PuboFileSystem } from './file-system';
|