geonix 1.8.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonix",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "bin": {
package/src/Connection.js CHANGED
@@ -103,14 +103,22 @@ 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
- const response = await this.#nc.subscribe(respondTo, { max: 1, ...options })
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)
110
118
  }
111
119
 
112
120
  async subscribe(subject, options) {
113
- return await this.#nc.subscribe(subject, options)
121
+ return this.#nc.subscribe(subject, options)
114
122
  }
115
123
 
116
124
  async unsubscribe(subscription) {
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
- let response = await connection.request(
81
- `gx2.service.${hash(identifier)}`,
82
- {
83
- m: method,
84
- a: args,
85
- c: context,
86
- o: getOriginator()
87
- },
88
- options)
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)
package/src/Stream.js CHANGED
@@ -28,15 +28,12 @@ export function Stream(data) {
28
28
  readable = transform
29
29
 
30
30
  const controlHandler = async () => {
31
- const control = await connection.subscribe(`gx2.stream.${id}.a`)
31
+ const control = await connection.subscribe(`gx2.stream.${id}.a`, { max: 1 })
32
32
 
33
33
  for await (const event of control)
34
34
  if (event.data.length === 0) {
35
35
  readable.on('data', chunk => connection.publishRaw(`gx2.stream.${id}.b`, chunk))
36
- readable.on('close', () => {
37
- connection.publishRaw(`gx2.stream.${id}.b`)
38
- control.drain()
39
- })
36
+ readable.on('close', () => connection.publishRaw(`gx2.stream.${id}.b`))
40
37
  }
41
38
  }
42
39