@xuda.io/account_module 1.2.2014 → 1.2.2016
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/index_ms.mjs +17 -10
- package/package.json +1 -1
package/index_ms.mjs
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import amqplib from 'amqplib';
|
|
7
7
|
|
|
8
|
+
let queue={}
|
|
9
|
+
|
|
8
10
|
// --- AMQP Connection & Channel ---
|
|
9
11
|
const conn = await amqplib.connect('amqp://localhost');
|
|
10
12
|
const channel = await conn.createChannel();
|
|
@@ -33,16 +35,21 @@ import amqplib from 'amqplib';
|
|
|
33
35
|
|
|
34
36
|
const send_to_queue =async function(ms_method, ...args) {
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const queue_id=Date.now()
|
|
39
|
+
queue[queue_id]= new Promise(()=>{
|
|
40
|
+
|
|
41
|
+
global[`_${global.module_in}_ch`].sendToQueue(
|
|
42
|
+
'account_module',
|
|
43
|
+
Buffer.from(
|
|
44
|
+
JSON.stringify({
|
|
45
|
+
ms_method,
|
|
46
|
+
data: args,
|
|
47
|
+
cb:`_account_module-${global.module_in}_ch`
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
})
|
|
46
53
|
};
|
|
47
54
|
|
|
48
55
|
// You must define this somewhere before using these wrappers:
|