geonix 1.8.1 → 1.8.2
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/package.json +1 -1
- package/src/Connection.js +9 -1
- package/src/Request.js +14 -9
- package/src/Serialization.js +33 -0
package/package.json
CHANGED
package/src/Connection.js
CHANGED
|
@@ -103,7 +103,15 @@ class Connection {
|
|
|
103
103
|
payload = codec.encode(Stream(JSON.stringify({ $r: respondTo, p: json })))
|
|
104
104
|
|
|
105
105
|
await this.#nc.publish(subject, payload)
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const response = await this.#nc.subscribe(respondTo, { max: 1, ...options })
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.debug('GxDebug -----')
|
|
111
|
+
console.log({ subject, json })
|
|
112
|
+
console.debug('-------------')
|
|
113
|
+
throw e
|
|
114
|
+
}
|
|
107
115
|
|
|
108
116
|
for await (let event of response)
|
|
109
117
|
return codec.decode(event.data)
|
package/src/Request.js
CHANGED
|
@@ -77,15 +77,20 @@ export async function Request(service, method, args = [], context = [], options)
|
|
|
77
77
|
if (!identifier)
|
|
78
78
|
throw Error(`Request: requested instance of ${service} not found`)
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
try {
|
|
81
|
+
const originator = getOriginator()
|
|
82
|
+
let response = await connection.request(
|
|
83
|
+
`gx2.service.${hash(identifier)}`,
|
|
84
|
+
{
|
|
85
|
+
m: method,
|
|
86
|
+
a: args,
|
|
87
|
+
c: context,
|
|
88
|
+
o: originator
|
|
89
|
+
},
|
|
90
|
+
options)
|
|
91
|
+
} catch (e) {
|
|
92
|
+
|
|
93
|
+
}
|
|
89
94
|
|
|
90
95
|
// automatically process streamed response
|
|
91
96
|
if (isStream(response))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function serialize(input) {
|
|
2
|
+
const process = (value) => {
|
|
3
|
+
if (value instanceof Buffer) {
|
|
4
|
+
console.log('this is buffer')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (typeof value === 'object')
|
|
8
|
+
for (let prop in value)
|
|
9
|
+
serialize()
|
|
10
|
+
|
|
11
|
+
return value
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let state = input
|
|
15
|
+
|
|
16
|
+
process(state)
|
|
17
|
+
|
|
18
|
+
return JSON.stringify(state)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function deserialize(input) {
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const input = {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const s = serialize(input)
|
|
30
|
+
const ds = deserialize(s)
|
|
31
|
+
|
|
32
|
+
console.log(' serialized =', s)
|
|
33
|
+
console.log('deserialized =', ds)
|