pubo-node 1.0.35-alpha.0 → 1.0.36
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/grpc/index.d.ts +6 -6
- package/es/grpc/index.js +37 -7
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/rtsp-video/index.d.ts +15 -0
- package/es/rtsp-video/index.js +50 -0
- package/es/rtsp-video/rtsp2mpeg.d.ts +13 -0
- package/es/rtsp-video/rtsp2mpeg.js +125 -0
- package/lib/grpc/index.d.ts +6 -6
- package/lib/grpc/index.js +39 -9
- package/lib/index.d.ts +2 -2
- package/lib/index.js +11 -11
- package/lib/rtsp-video/index.d.ts +15 -0
- package/lib/rtsp-video/index.js +58 -0
- package/lib/rtsp-video/rtsp2mpeg.d.ts +13 -0
- package/lib/rtsp-video/rtsp2mpeg.js +133 -0
- package/package.json +2 -2
- package/es/grpc/Grpc.d.ts +0 -15
- package/es/grpc/Grpc.js +0 -52
- package/es/grpc/GrpcPool.d.ts +0 -14
- package/es/grpc/GrpcPool.js +0 -43
- package/es/grpc/GrpcService.d.ts +0 -13
- package/es/grpc/GrpcService.js +0 -295
- package/lib/grpc/Grpc.d.ts +0 -15
- package/lib/grpc/Grpc.js +0 -93
- package/lib/grpc/GrpcPool.d.ts +0 -14
- package/lib/grpc/GrpcPool.js +0 -50
- package/lib/grpc/GrpcService.d.ts +0 -13
- package/lib/grpc/GrpcService.js +0 -302
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"pako": "^2.0.4",
|
|
25
25
|
"pubo-utils": "^1.0.35-alpha.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "093174bba2f8ec71052a5a47c33b64ee26d528e3"
|
|
28
28
|
}
|
package/es/grpc/Grpc.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface GrpcConfig {
|
|
2
|
-
root: string;
|
|
3
|
-
url: string;
|
|
4
|
-
options?: any;
|
|
5
|
-
}
|
|
6
|
-
export declare class Grpc {
|
|
7
|
-
private readonly config;
|
|
8
|
-
private readonly options;
|
|
9
|
-
private instance;
|
|
10
|
-
private readonly RpcClient;
|
|
11
|
-
common: any;
|
|
12
|
-
proto: any;
|
|
13
|
-
constructor(conf: GrpcConfig);
|
|
14
|
-
get client(): any;
|
|
15
|
-
}
|
package/es/grpc/Grpc.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __assign = this && this.__assign || function () {
|
|
2
|
-
__assign = Object.assign || function (t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
|
|
6
|
-
for (var p in s) {
|
|
7
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
import * as grpc from 'grpc';
|
|
18
|
-
|
|
19
|
-
var Grpc =
|
|
20
|
-
/** @class */
|
|
21
|
-
function () {
|
|
22
|
-
function Grpc(conf) {
|
|
23
|
-
this.options = {
|
|
24
|
-
'grpc.max_send_message_length': -1,
|
|
25
|
-
'grpc.max_receive_message_length': -1
|
|
26
|
-
};
|
|
27
|
-
this.instance = null;
|
|
28
|
-
this.config = conf;
|
|
29
|
-
this.common = require(this.config.root + "/common_pb"); // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
|
-
|
|
31
|
-
this.RpcClient = require(this.config.root + "/service_grpc_pb").RpcClient;
|
|
32
|
-
this.proto = global.proto;
|
|
33
|
-
global.proto = {};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(Grpc.prototype, "client", {
|
|
37
|
-
get: function get() {
|
|
38
|
-
if (!this.instance) {
|
|
39
|
-
var options = __assign(__assign({}, this.options), this.config.options || {});
|
|
40
|
-
|
|
41
|
-
this.instance = new this.RpcClient(this.config.url, grpc.credentials.createInsecure(), options);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return this.instance;
|
|
45
|
-
},
|
|
46
|
-
enumerable: false,
|
|
47
|
-
configurable: true
|
|
48
|
-
});
|
|
49
|
-
return Grpc;
|
|
50
|
-
}();
|
|
51
|
-
|
|
52
|
-
export { Grpc };
|
package/es/grpc/GrpcPool.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GrpcConfig } from './Grpc';
|
|
2
|
-
import { Grpc } from './Grpc';
|
|
3
|
-
export declare type GrpcPoolType = (GrpcConfig & {
|
|
4
|
-
id: any;
|
|
5
|
-
})[];
|
|
6
|
-
export declare class GrpcPool {
|
|
7
|
-
static pool: GrpcPoolType;
|
|
8
|
-
private static instance;
|
|
9
|
-
static getPool: () => GrpcPool;
|
|
10
|
-
static setPool: (pool: GrpcPoolType) => void;
|
|
11
|
-
private readonly list;
|
|
12
|
-
constructor(list: GrpcPoolType);
|
|
13
|
-
getGrpc(id: string): Grpc | undefined;
|
|
14
|
-
}
|
package/es/grpc/GrpcPool.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Grpc } from './Grpc';
|
|
2
|
-
|
|
3
|
-
var GrpcPool =
|
|
4
|
-
/** @class */
|
|
5
|
-
function () {
|
|
6
|
-
function GrpcPool(list) {
|
|
7
|
-
this.list = [];
|
|
8
|
-
this.list = list.map(function (conf) {
|
|
9
|
-
return {
|
|
10
|
-
id: conf.id,
|
|
11
|
-
grpc: new Grpc(conf)
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
GrpcPool.prototype.getGrpc = function (id) {
|
|
17
|
-
var _a;
|
|
18
|
-
|
|
19
|
-
return (_a = this.list.find(function (item) {
|
|
20
|
-
return item.id === id;
|
|
21
|
-
})) === null || _a === void 0 ? void 0 : _a.grpc;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
GrpcPool.pool = [];
|
|
25
|
-
GrpcPool.instance = null;
|
|
26
|
-
|
|
27
|
-
GrpcPool.getPool = function () {
|
|
28
|
-
if (!GrpcPool.instance) {
|
|
29
|
-
GrpcPool.instance = new GrpcPool(GrpcPool.pool);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return GrpcPool.instance;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
GrpcPool.setPool = function (pool) {
|
|
36
|
-
GrpcPool.pool = pool;
|
|
37
|
-
GrpcPool.instance = new GrpcPool(GrpcPool.pool);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return GrpcPool;
|
|
41
|
-
}();
|
|
42
|
-
|
|
43
|
-
export { GrpcPool };
|
package/es/grpc/GrpcService.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface GrpcServiceConfig {
|
|
2
|
-
client: string;
|
|
3
|
-
serviceName: string;
|
|
4
|
-
requestType: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class GrpcService {
|
|
7
|
-
private readonly config;
|
|
8
|
-
private readonly grpc?;
|
|
9
|
-
private readonly promise;
|
|
10
|
-
constructor(conf: GrpcServiceConfig);
|
|
11
|
-
serializer(requestType: string, payload?: any): any;
|
|
12
|
-
send(request?: any): Promise<any>;
|
|
13
|
-
}
|
package/es/grpc/GrpcService.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) {
|
|
3
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
4
|
-
resolve(value);
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) {
|
|
10
|
-
try {
|
|
11
|
-
step(generator.next(value));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
reject(e);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function step(result) {
|
|
26
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
34
|
-
var _ = {
|
|
35
|
-
label: 0,
|
|
36
|
-
sent: function sent() {
|
|
37
|
-
if (t[0] & 1) throw t[1];
|
|
38
|
-
return t[1];
|
|
39
|
-
},
|
|
40
|
-
trys: [],
|
|
41
|
-
ops: []
|
|
42
|
-
},
|
|
43
|
-
f,
|
|
44
|
-
y,
|
|
45
|
-
t,
|
|
46
|
-
g;
|
|
47
|
-
return g = {
|
|
48
|
-
next: verb(0),
|
|
49
|
-
"throw": verb(1),
|
|
50
|
-
"return": verb(2)
|
|
51
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
52
|
-
return this;
|
|
53
|
-
}), g;
|
|
54
|
-
|
|
55
|
-
function verb(n) {
|
|
56
|
-
return function (v) {
|
|
57
|
-
return step([n, v]);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function step(op) {
|
|
62
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
63
|
-
|
|
64
|
-
while (_) {
|
|
65
|
-
try {
|
|
66
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
68
|
-
|
|
69
|
-
switch (op[0]) {
|
|
70
|
-
case 0:
|
|
71
|
-
case 1:
|
|
72
|
-
t = op;
|
|
73
|
-
break;
|
|
74
|
-
|
|
75
|
-
case 4:
|
|
76
|
-
_.label++;
|
|
77
|
-
return {
|
|
78
|
-
value: op[1],
|
|
79
|
-
done: false
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
case 5:
|
|
83
|
-
_.label++;
|
|
84
|
-
y = op[1];
|
|
85
|
-
op = [0];
|
|
86
|
-
continue;
|
|
87
|
-
|
|
88
|
-
case 7:
|
|
89
|
-
op = _.ops.pop();
|
|
90
|
-
|
|
91
|
-
_.trys.pop();
|
|
92
|
-
|
|
93
|
-
continue;
|
|
94
|
-
|
|
95
|
-
default:
|
|
96
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
97
|
-
_ = 0;
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
102
|
-
_.label = op[1];
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
107
|
-
_.label = t[1];
|
|
108
|
-
t = op;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (t && _.label < t[2]) {
|
|
113
|
-
_.label = t[2];
|
|
114
|
-
|
|
115
|
-
_.ops.push(op);
|
|
116
|
-
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (t[2]) _.ops.pop();
|
|
121
|
-
|
|
122
|
-
_.trys.pop();
|
|
123
|
-
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
op = body.call(thisArg, _);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
op = [6, e];
|
|
130
|
-
y = 0;
|
|
131
|
-
} finally {
|
|
132
|
-
f = t = 0;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (op[0] & 5) throw op[1];
|
|
137
|
-
return {
|
|
138
|
-
value: op[0] ? op[1] : void 0,
|
|
139
|
-
done: true
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
var __read = this && this.__read || function (o, n) {
|
|
145
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
146
|
-
if (!m) return o;
|
|
147
|
-
var i = m.call(o),
|
|
148
|
-
r,
|
|
149
|
-
ar = [],
|
|
150
|
-
e;
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
154
|
-
ar.push(r.value);
|
|
155
|
-
}
|
|
156
|
-
} catch (error) {
|
|
157
|
-
e = {
|
|
158
|
-
error: error
|
|
159
|
-
};
|
|
160
|
-
} finally {
|
|
161
|
-
try {
|
|
162
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
163
|
-
} finally {
|
|
164
|
-
if (e) throw e.error;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return ar;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
var __spread = this && this.__spread || function () {
|
|
172
|
-
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
173
|
-
ar = ar.concat(__read(arguments[i]));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return ar;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
var __values = this && this.__values || function (o) {
|
|
180
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
181
|
-
m = s && o[s],
|
|
182
|
-
i = 0;
|
|
183
|
-
if (m) return m.call(o);
|
|
184
|
-
if (o && typeof o.length === "number") return {
|
|
185
|
-
next: function next() {
|
|
186
|
-
if (o && i >= o.length) o = void 0;
|
|
187
|
-
return {
|
|
188
|
-
value: o && o[i++],
|
|
189
|
-
done: !o
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
import { GrpcPool } from './GrpcPool';
|
|
197
|
-
|
|
198
|
-
function createRpcPromise(fn, grpc) {
|
|
199
|
-
return function () {
|
|
200
|
-
var args = [];
|
|
201
|
-
|
|
202
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
203
|
-
args[_i] = arguments[_i];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return new Promise(function (resolve, reject) {
|
|
207
|
-
var client = grpc.client;
|
|
208
|
-
fn.call.apply(fn, __spread([client], args, [function (err, response) {
|
|
209
|
-
global.proto = grpc.proto;
|
|
210
|
-
|
|
211
|
-
if (err) {
|
|
212
|
-
reject(err);
|
|
213
|
-
} else {
|
|
214
|
-
resolve(response);
|
|
215
|
-
}
|
|
216
|
-
}]));
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
var GrpcService =
|
|
222
|
-
/** @class */
|
|
223
|
-
function () {
|
|
224
|
-
function GrpcService(conf) {
|
|
225
|
-
this.config = conf;
|
|
226
|
-
this.grpc = GrpcPool.getPool().getGrpc(this.config.client);
|
|
227
|
-
|
|
228
|
-
if (!this.grpc || !this.grpc.client[this.config.serviceName]) {
|
|
229
|
-
throw new Error("rpc service not found:" + this.config.serviceName);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
this.promise = createRpcPromise(this.grpc.client[this.config.serviceName], this.grpc);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
GrpcService.prototype.serializer = function (requestType, payload) {
|
|
236
|
-
var e_1, _a;
|
|
237
|
-
|
|
238
|
-
if (payload === void 0) {
|
|
239
|
-
payload = {};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (!this.grpc) {
|
|
243
|
-
throw new Error("rpc client not found:" + this.config.client);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
global.proto = this.grpc.proto;
|
|
247
|
-
var request = new this.grpc.common[requestType]();
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
for (var _b = __values(Object.keys(request.toObject())), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
251
|
-
var key = _c.value;
|
|
252
|
-
|
|
253
|
-
if (payload[key] !== undefined) {
|
|
254
|
-
request["set" + key[0].toUpperCase() + key.slice(1)](payload[key]);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
} catch (e_1_1) {
|
|
258
|
-
e_1 = {
|
|
259
|
-
error: e_1_1
|
|
260
|
-
};
|
|
261
|
-
} finally {
|
|
262
|
-
try {
|
|
263
|
-
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
264
|
-
} finally {
|
|
265
|
-
if (e_1) throw e_1.error;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return request;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
GrpcService.prototype.send = function (request) {
|
|
273
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
274
|
-
var res;
|
|
275
|
-
return __generator(this, function (_a) {
|
|
276
|
-
switch (_a.label) {
|
|
277
|
-
case 0:
|
|
278
|
-
return [4
|
|
279
|
-
/*yield*/
|
|
280
|
-
, this.promise(this.serializer(this.config.requestType, request))];
|
|
281
|
-
|
|
282
|
-
case 1:
|
|
283
|
-
res = _a.sent();
|
|
284
|
-
return [2
|
|
285
|
-
/*return*/
|
|
286
|
-
, res.toObject()];
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
return GrpcService;
|
|
293
|
-
}();
|
|
294
|
-
|
|
295
|
-
export { GrpcService };
|
package/lib/grpc/Grpc.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface GrpcConfig {
|
|
2
|
-
root: string;
|
|
3
|
-
url: string;
|
|
4
|
-
options?: any;
|
|
5
|
-
}
|
|
6
|
-
export declare class Grpc {
|
|
7
|
-
private readonly config;
|
|
8
|
-
private readonly options;
|
|
9
|
-
private instance;
|
|
10
|
-
private readonly RpcClient;
|
|
11
|
-
common: any;
|
|
12
|
-
proto: any;
|
|
13
|
-
constructor(conf: GrpcConfig);
|
|
14
|
-
get client(): any;
|
|
15
|
-
}
|
package/lib/grpc/Grpc.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __assign = this && this.__assign || function () {
|
|
4
|
-
__assign = Object.assign || function (t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
|
|
8
|
-
for (var p in s) {
|
|
9
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
20
|
-
if (k2 === undefined) k2 = k;
|
|
21
|
-
Object.defineProperty(o, k2, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function get() {
|
|
24
|
-
return m[k];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
} : function (o, m, k, k2) {
|
|
28
|
-
if (k2 === undefined) k2 = k;
|
|
29
|
-
o[k2] = m[k];
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
|
33
|
-
Object.defineProperty(o, "default", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
value: v
|
|
36
|
-
});
|
|
37
|
-
} : function (o, v) {
|
|
38
|
-
o["default"] = v;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
var __importStar = this && this.__importStar || function (mod) {
|
|
42
|
-
if (mod && mod.__esModule) return mod;
|
|
43
|
-
var result = {};
|
|
44
|
-
if (mod != null) for (var k in mod) {
|
|
45
|
-
if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
__setModuleDefault(result, mod);
|
|
49
|
-
|
|
50
|
-
return result;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(exports, "__esModule", {
|
|
54
|
-
value: true
|
|
55
|
-
});
|
|
56
|
-
exports.Grpc = void 0;
|
|
57
|
-
|
|
58
|
-
var grpc = __importStar(require("grpc"));
|
|
59
|
-
|
|
60
|
-
var Grpc =
|
|
61
|
-
/** @class */
|
|
62
|
-
function () {
|
|
63
|
-
function Grpc(conf) {
|
|
64
|
-
this.options = {
|
|
65
|
-
'grpc.max_send_message_length': -1,
|
|
66
|
-
'grpc.max_receive_message_length': -1
|
|
67
|
-
};
|
|
68
|
-
this.instance = null;
|
|
69
|
-
this.config = conf;
|
|
70
|
-
this.common = require(this.config.root + "/common_pb"); // eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
71
|
-
|
|
72
|
-
this.RpcClient = require(this.config.root + "/service_grpc_pb").RpcClient;
|
|
73
|
-
this.proto = global.proto;
|
|
74
|
-
global.proto = {};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
Object.defineProperty(Grpc.prototype, "client", {
|
|
78
|
-
get: function get() {
|
|
79
|
-
if (!this.instance) {
|
|
80
|
-
var options = __assign(__assign({}, this.options), this.config.options || {});
|
|
81
|
-
|
|
82
|
-
this.instance = new this.RpcClient(this.config.url, grpc.credentials.createInsecure(), options);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return this.instance;
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
|
-
return Grpc;
|
|
91
|
-
}();
|
|
92
|
-
|
|
93
|
-
exports.Grpc = Grpc;
|
package/lib/grpc/GrpcPool.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GrpcConfig } from './Grpc';
|
|
2
|
-
import { Grpc } from './Grpc';
|
|
3
|
-
export declare type GrpcPoolType = (GrpcConfig & {
|
|
4
|
-
id: any;
|
|
5
|
-
})[];
|
|
6
|
-
export declare class GrpcPool {
|
|
7
|
-
static pool: GrpcPoolType;
|
|
8
|
-
private static instance;
|
|
9
|
-
static getPool: () => GrpcPool;
|
|
10
|
-
static setPool: (pool: GrpcPoolType) => void;
|
|
11
|
-
private readonly list;
|
|
12
|
-
constructor(list: GrpcPoolType);
|
|
13
|
-
getGrpc(id: string): Grpc | undefined;
|
|
14
|
-
}
|
package/lib/grpc/GrpcPool.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GrpcPool = void 0;
|
|
7
|
-
|
|
8
|
-
var Grpc_1 = require("./Grpc");
|
|
9
|
-
|
|
10
|
-
var GrpcPool =
|
|
11
|
-
/** @class */
|
|
12
|
-
function () {
|
|
13
|
-
function GrpcPool(list) {
|
|
14
|
-
this.list = [];
|
|
15
|
-
this.list = list.map(function (conf) {
|
|
16
|
-
return {
|
|
17
|
-
id: conf.id,
|
|
18
|
-
grpc: new Grpc_1.Grpc(conf)
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
GrpcPool.prototype.getGrpc = function (id) {
|
|
24
|
-
var _a;
|
|
25
|
-
|
|
26
|
-
return (_a = this.list.find(function (item) {
|
|
27
|
-
return item.id === id;
|
|
28
|
-
})) === null || _a === void 0 ? void 0 : _a.grpc;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
GrpcPool.pool = [];
|
|
32
|
-
GrpcPool.instance = null;
|
|
33
|
-
|
|
34
|
-
GrpcPool.getPool = function () {
|
|
35
|
-
if (!GrpcPool.instance) {
|
|
36
|
-
GrpcPool.instance = new GrpcPool(GrpcPool.pool);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return GrpcPool.instance;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
GrpcPool.setPool = function (pool) {
|
|
43
|
-
GrpcPool.pool = pool;
|
|
44
|
-
GrpcPool.instance = new GrpcPool(GrpcPool.pool);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return GrpcPool;
|
|
48
|
-
}();
|
|
49
|
-
|
|
50
|
-
exports.GrpcPool = GrpcPool;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface GrpcServiceConfig {
|
|
2
|
-
client: string;
|
|
3
|
-
serviceName: string;
|
|
4
|
-
requestType: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class GrpcService {
|
|
7
|
-
private readonly config;
|
|
8
|
-
private readonly grpc?;
|
|
9
|
-
private readonly promise;
|
|
10
|
-
constructor(conf: GrpcServiceConfig);
|
|
11
|
-
serializer(requestType: string, payload?: any): any;
|
|
12
|
-
send(request?: any): Promise<any>;
|
|
13
|
-
}
|