@sentio/runtime 2.39.4-rc.6 → 2.39.4-rc.7
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/lib/db-context.d.ts +5 -184
- package/lib/db-context.d.ts.map +1 -1
- package/lib/db-context.js +10 -5
- package/lib/db-context.js.map +1 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +14 -7
- package/lib/service.js.map +1 -1
- package/package.json +2 -2
- package/src/db-context.ts +8 -4
- package/src/service.ts +17 -7
package/lib/db-context.d.ts
CHANGED
@@ -1,191 +1,12 @@
|
|
1
1
|
import { Subject } from 'rxjs';
|
2
|
-
import { DBRequest, DBResponse, DeepPartial } from '@sentio/protos';
|
2
|
+
import { DBRequest, DBResponse, DeepPartial, ProcessStreamResponse } from '@sentio/protos';
|
3
3
|
type Request = Omit<DBRequest, 'opId'>;
|
4
4
|
export declare class StoreContext {
|
5
|
-
|
5
|
+
readonly subject: Subject<DeepPartial<ProcessStreamResponse>>;
|
6
|
+
readonly processId: number;
|
7
|
+
private static opCounter;
|
6
8
|
private defers;
|
7
|
-
subject: Subject<
|
8
|
-
processId?: number | undefined;
|
9
|
-
dbRequest?: {
|
10
|
-
opId?: bigint | undefined;
|
11
|
-
get?: {
|
12
|
-
entity?: string | undefined;
|
13
|
-
id?: string | undefined;
|
14
|
-
} | undefined;
|
15
|
-
upsert?: {
|
16
|
-
entity?: string[] | undefined;
|
17
|
-
id?: string[] | undefined;
|
18
|
-
data?: {
|
19
|
-
[x: string]: any;
|
20
|
-
}[] | undefined;
|
21
|
-
entityData?: {
|
22
|
-
fields?: {
|
23
|
-
[x: string]: {
|
24
|
-
nullValue?: import("@sentio/protos").RichValue_NullValue | undefined;
|
25
|
-
intValue?: number | undefined;
|
26
|
-
floatValue?: number | undefined;
|
27
|
-
bytesValue?: Uint8Array | undefined;
|
28
|
-
boolValue?: boolean | undefined;
|
29
|
-
stringValue?: string | undefined;
|
30
|
-
timestampValue?: Date | undefined;
|
31
|
-
bigintValue?: {
|
32
|
-
negative?: boolean | undefined;
|
33
|
-
data?: Uint8Array | undefined;
|
34
|
-
} | undefined;
|
35
|
-
bigdecimalValue?: {
|
36
|
-
value?: {
|
37
|
-
negative?: boolean | undefined;
|
38
|
-
data?: Uint8Array | undefined;
|
39
|
-
} | undefined;
|
40
|
-
exp?: number | undefined;
|
41
|
-
} | undefined;
|
42
|
-
listValue?: {
|
43
|
-
values?: any[] | undefined;
|
44
|
-
} | undefined;
|
45
|
-
} | undefined;
|
46
|
-
} | undefined;
|
47
|
-
}[] | undefined;
|
48
|
-
} | undefined;
|
49
|
-
delete?: {
|
50
|
-
entity?: string[] | undefined;
|
51
|
-
id?: string[] | undefined;
|
52
|
-
} | undefined;
|
53
|
-
list?: {
|
54
|
-
entity?: string | undefined;
|
55
|
-
filters?: {
|
56
|
-
field?: string | undefined;
|
57
|
-
op?: import("@sentio/protos").DBRequest_DBOperator | undefined;
|
58
|
-
value?: {
|
59
|
-
values?: {
|
60
|
-
nullValue?: import("@sentio/protos").RichValue_NullValue | undefined;
|
61
|
-
intValue?: number | undefined;
|
62
|
-
floatValue?: number | undefined;
|
63
|
-
bytesValue?: Uint8Array | undefined;
|
64
|
-
boolValue?: boolean | undefined;
|
65
|
-
stringValue?: string | undefined;
|
66
|
-
timestampValue?: Date | undefined;
|
67
|
-
bigintValue?: {
|
68
|
-
negative?: boolean | undefined;
|
69
|
-
data?: Uint8Array | undefined;
|
70
|
-
} | undefined;
|
71
|
-
bigdecimalValue?: {
|
72
|
-
value?: {
|
73
|
-
negative?: boolean | undefined;
|
74
|
-
data?: Uint8Array | undefined;
|
75
|
-
} | undefined;
|
76
|
-
exp?: number | undefined;
|
77
|
-
} | undefined;
|
78
|
-
listValue?: any | undefined;
|
79
|
-
}[] | undefined;
|
80
|
-
} | undefined;
|
81
|
-
}[] | undefined;
|
82
|
-
cursor?: string | undefined;
|
83
|
-
} | undefined;
|
84
|
-
} | undefined;
|
85
|
-
result?: {
|
86
|
-
gauges?: {
|
87
|
-
metadata?: {
|
88
|
-
address?: string | undefined;
|
89
|
-
contractName?: string | undefined;
|
90
|
-
blockNumber?: bigint | undefined;
|
91
|
-
transactionHash?: string | undefined;
|
92
|
-
chainId?: string | undefined;
|
93
|
-
transactionIndex?: number | undefined;
|
94
|
-
logIndex?: number | undefined;
|
95
|
-
name?: string | undefined;
|
96
|
-
labels?: {
|
97
|
-
[x: string]: string | undefined;
|
98
|
-
} | undefined;
|
99
|
-
} | undefined;
|
100
|
-
metricValue?: {
|
101
|
-
bigDecimal?: string | undefined;
|
102
|
-
doubleValue?: number | undefined;
|
103
|
-
bigInteger?: {
|
104
|
-
negative?: boolean | undefined;
|
105
|
-
data?: Uint8Array | undefined;
|
106
|
-
} | undefined;
|
107
|
-
} | undefined;
|
108
|
-
runtimeInfo?: {
|
109
|
-
from?: import("@sentio/protos").HandlerType | undefined;
|
110
|
-
} | undefined;
|
111
|
-
}[] | undefined;
|
112
|
-
counters?: {
|
113
|
-
metadata?: {
|
114
|
-
address?: string | undefined;
|
115
|
-
contractName?: string | undefined;
|
116
|
-
blockNumber?: bigint | undefined;
|
117
|
-
transactionHash?: string | undefined;
|
118
|
-
chainId?: string | undefined;
|
119
|
-
transactionIndex?: number | undefined;
|
120
|
-
logIndex?: number | undefined;
|
121
|
-
name?: string | undefined;
|
122
|
-
labels?: {
|
123
|
-
[x: string]: string | undefined;
|
124
|
-
} | undefined;
|
125
|
-
} | undefined;
|
126
|
-
metricValue?: {
|
127
|
-
bigDecimal?: string | undefined;
|
128
|
-
doubleValue?: number | undefined;
|
129
|
-
bigInteger?: {
|
130
|
-
negative?: boolean | undefined;
|
131
|
-
data?: Uint8Array | undefined;
|
132
|
-
} | undefined;
|
133
|
-
} | undefined;
|
134
|
-
add?: boolean | undefined;
|
135
|
-
runtimeInfo?: {
|
136
|
-
from?: import("@sentio/protos").HandlerType | undefined;
|
137
|
-
} | undefined;
|
138
|
-
}[] | undefined;
|
139
|
-
events?: {
|
140
|
-
metadata?: {
|
141
|
-
address?: string | undefined;
|
142
|
-
contractName?: string | undefined;
|
143
|
-
blockNumber?: bigint | undefined;
|
144
|
-
transactionHash?: string | undefined;
|
145
|
-
chainId?: string | undefined;
|
146
|
-
transactionIndex?: number | undefined;
|
147
|
-
logIndex?: number | undefined;
|
148
|
-
name?: string | undefined;
|
149
|
-
labels?: {
|
150
|
-
[x: string]: string | undefined;
|
151
|
-
} | undefined;
|
152
|
-
} | undefined;
|
153
|
-
distinctEntityId?: string | undefined;
|
154
|
-
attributes?: {
|
155
|
-
[x: string]: any;
|
156
|
-
} | undefined;
|
157
|
-
severity?: import("@sentio/protos").LogLevel | undefined;
|
158
|
-
message?: string | undefined;
|
159
|
-
runtimeInfo?: {
|
160
|
-
from?: import("@sentio/protos").HandlerType | undefined;
|
161
|
-
} | undefined;
|
162
|
-
noMetric?: boolean | undefined;
|
163
|
-
}[] | undefined;
|
164
|
-
exports?: {
|
165
|
-
metadata?: {
|
166
|
-
address?: string | undefined;
|
167
|
-
contractName?: string | undefined;
|
168
|
-
blockNumber?: bigint | undefined;
|
169
|
-
transactionHash?: string | undefined;
|
170
|
-
chainId?: string | undefined;
|
171
|
-
transactionIndex?: number | undefined;
|
172
|
-
logIndex?: number | undefined;
|
173
|
-
name?: string | undefined;
|
174
|
-
labels?: {
|
175
|
-
[x: string]: string | undefined;
|
176
|
-
} | undefined;
|
177
|
-
} | undefined;
|
178
|
-
payload?: string | undefined;
|
179
|
-
runtimeInfo?: {
|
180
|
-
from?: import("@sentio/protos").HandlerType | undefined;
|
181
|
-
} | undefined;
|
182
|
-
}[] | undefined;
|
183
|
-
states?: {
|
184
|
-
configUpdated?: boolean | undefined;
|
185
|
-
error?: string | undefined;
|
186
|
-
} | undefined;
|
187
|
-
} | undefined;
|
188
|
-
}>;
|
9
|
+
constructor(subject: Subject<DeepPartial<ProcessStreamResponse>>, processId: number);
|
189
10
|
newPromise<T>(opId: bigint): Promise<T>;
|
190
11
|
sendRequest(request: DeepPartial<Request>): Promise<unknown>;
|
191
12
|
result(dbResult: DBResponse): void;
|
package/lib/db-context.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"db-context.d.ts","sourceRoot":"","sources":["../src/db-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,
|
1
|
+
{"version":3,"file":"db-context.d.ts","sourceRoot":"","sources":["../src/db-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAiB,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAEzG,KAAK,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAEtC,qBAAa,YAAY;IAMrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC7D,QAAQ,CAAC,SAAS,EAAE,MAAM;IAN5B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAK;IAE7B,OAAO,CAAC,MAAM,CAAuF;gBAG1F,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC,EACpD,SAAS,EAAE,MAAM;IAG5B,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM;IAM1B,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;IAczC,MAAM,CAAC,QAAQ,EAAE,UAAU;IAc3B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG;CAYhC"}
|
package/lib/db-context.js
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
import { Subject } from 'rxjs';
|
2
1
|
import { ProcessResult } from '@sentio/protos';
|
3
2
|
export class StoreContext {
|
4
|
-
|
3
|
+
subject;
|
4
|
+
processId;
|
5
|
+
static opCounter = 0n;
|
5
6
|
defers = new Map();
|
6
|
-
subject
|
7
|
+
constructor(subject, processId) {
|
8
|
+
this.subject = subject;
|
9
|
+
this.processId = processId;
|
10
|
+
}
|
7
11
|
newPromise(opId) {
|
8
12
|
return new Promise((resolve, reject) => {
|
9
13
|
this.defers.set(opId, { resolve, reject });
|
10
14
|
});
|
11
15
|
}
|
12
16
|
sendRequest(request) {
|
13
|
-
const opId =
|
17
|
+
const opId = StoreContext.opCounter++;
|
14
18
|
const promise = this.newPromise(opId);
|
15
19
|
console.debug('sending db request ', opId, request);
|
16
20
|
this.subject.next({
|
17
21
|
dbRequest: {
|
18
22
|
...request,
|
19
23
|
opId
|
20
|
-
}
|
24
|
+
},
|
25
|
+
processId: this.processId
|
21
26
|
});
|
22
27
|
return promise;
|
23
28
|
}
|
package/lib/db-context.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"db-context.js","sourceRoot":"","sources":["../src/db-context.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"db-context.js","sourceRoot":"","sources":["../src/db-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,aAAa,EAAyB,MAAM,gBAAgB,CAAA;AAIzG,MAAM,OAAO,YAAY;IAMZ;IACA;IANH,MAAM,CAAC,SAAS,GAAG,EAAE,CAAA;IAErB,MAAM,GAAG,IAAI,GAAG,EAA6E,CAAA;IAErG,YACW,OAAoD,EACpD,SAAiB;QADjB,YAAO,GAAP,OAAO,CAA6C;QACpD,cAAS,GAAT,SAAS,CAAQ;IACzB,CAAC;IAEJ,UAAU,CAAI,IAAY;QACxB,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,WAAW,CAAC,OAA6B;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EAAE,WAAW;YACnB,SAAS;SACV,CAAC,CAAA;IACJ,CAAC"}
|
package/lib/service.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,WAAW,CAAA;AAK5D,OAAO,EACL,WAAW,
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,WAAW,CAAA;AAK5D,OAAO,EACL,WAAW,EAEX,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,oBAAoB,EAEpB,YAAY,EACb,MAAM,gBAAgB,CAAA;AAavB,qBAAa,oBAAqB,YAAW,8BAA8B;IACzE,OAAO,CAAC,OAAO,CAAQ;IAEvB,SAAS,EAAE,KAAK,CAAA;IAGhB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAE3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAY;gBAEjC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,EAAE,MAAM,IAAI;IAK9D,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoB9F,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAsClE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ1D,eAAe,CAAC,OAAO,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA6BxG,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBlF,qBAAqB,CAAC,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CjG"}
|
package/lib/service.js
CHANGED
@@ -7,6 +7,7 @@ import { PluginManager } from './plugin.js';
|
|
7
7
|
import { errorString, mergeProcessResults } from './utils.js';
|
8
8
|
import { freezeGlobalConfig, GLOBAL_CONFIG } from './global-config.js';
|
9
9
|
import { StoreContext } from './db-context.js';
|
10
|
+
import { Subject } from 'rxjs';
|
10
11
|
BigInt.prototype.toJSON = function () {
|
11
12
|
return this.toString();
|
12
13
|
};
|
@@ -124,38 +125,44 @@ export class ProcessorServiceImpl {
|
|
124
125
|
if (!this.started) {
|
125
126
|
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.');
|
126
127
|
}
|
127
|
-
const
|
128
|
+
const subject = new Subject();
|
129
|
+
const contexts = {};
|
128
130
|
new Promise(async (resolve, reject) => {
|
129
131
|
for await (const request of requests) {
|
130
132
|
if (request.binding) {
|
131
133
|
const binding = request.binding;
|
134
|
+
const dbContext = new StoreContext(subject, request.processId);
|
135
|
+
contexts[request.processId] = dbContext;
|
132
136
|
PluginManager.INSTANCE.processBinding(binding, dbContext)
|
133
137
|
.then((result) => {
|
134
|
-
|
138
|
+
subject.next({
|
135
139
|
result,
|
136
140
|
processId: request.processId
|
137
141
|
});
|
138
|
-
// dbContext.subject.complete()
|
139
142
|
recordRuntimeInfo(result, binding.handlerType);
|
140
143
|
})
|
141
144
|
.catch((e) => {
|
142
145
|
dbContext.error(request.processId, e);
|
146
|
+
})
|
147
|
+
.finally(() => {
|
148
|
+
delete contexts[request.processId];
|
143
149
|
});
|
144
150
|
}
|
145
151
|
if (request.dbResult) {
|
146
|
-
dbContext
|
152
|
+
const dbContext = contexts[request.processId];
|
153
|
+
dbContext?.result(request.dbResult);
|
147
154
|
}
|
148
155
|
}
|
149
156
|
resolve(null);
|
150
157
|
})
|
151
158
|
.then(() => {
|
152
|
-
|
159
|
+
subject.complete();
|
153
160
|
})
|
154
161
|
.catch((e) => {
|
155
162
|
// should not happen
|
156
|
-
|
163
|
+
subject.error(e);
|
157
164
|
});
|
158
|
-
yield* from(
|
165
|
+
yield* from(subject).pipe(withAbort(context.signal));
|
159
166
|
}
|
160
167
|
}
|
161
168
|
function recordRuntimeInfo(results, handlerType) {
|
package/lib/service.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAEhE,OAAO,
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAEhE,OAAO,EAQL,qBAAqB,EAMtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa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rC,CAAC;YACH,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC,CAAC;aACC,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,CAAC,QAAQ,EAAE,CAAA;QACpB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,oBAAoB;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC,CAAC,CAAA;QACJ,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
|
-
"version": "2.39.4-rc.
|
3
|
+
"version": "2.39.4-rc.7",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"rxjs": "^7.8.1",
|
33
33
|
"utility-types": "^3.11.0",
|
34
34
|
"winston": "^3.11.0",
|
35
|
-
"@sentio/protos": "2.39.4-rc.
|
35
|
+
"@sentio/protos": "2.39.4-rc.7"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"@types/command-line-args": "^5.2.3",
|
package/src/db-context.ts
CHANGED
@@ -4,11 +4,14 @@ import { DBRequest, DBResponse, DeepPartial, ProcessResult, ProcessStreamRespons
|
|
4
4
|
type Request = Omit<DBRequest, 'opId'>
|
5
5
|
|
6
6
|
export class StoreContext {
|
7
|
-
private opCounter = 0n
|
7
|
+
private static opCounter = 0n
|
8
8
|
|
9
9
|
private defers = new Map<bigint, { resolve: (value: any) => void; reject: (reason?: any) => void }>()
|
10
10
|
|
11
|
-
|
11
|
+
constructor(
|
12
|
+
readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
|
13
|
+
readonly processId: number
|
14
|
+
) {}
|
12
15
|
|
13
16
|
newPromise<T>(opId: bigint) {
|
14
17
|
return new Promise<T>((resolve, reject) => {
|
@@ -17,14 +20,15 @@ export class StoreContext {
|
|
17
20
|
}
|
18
21
|
|
19
22
|
sendRequest(request: DeepPartial<Request>) {
|
20
|
-
const opId =
|
23
|
+
const opId = StoreContext.opCounter++
|
21
24
|
const promise = this.newPromise(opId)
|
22
25
|
console.debug('sending db request ', opId, request)
|
23
26
|
this.subject.next({
|
24
27
|
dbRequest: {
|
25
28
|
...request,
|
26
29
|
opId
|
27
|
-
}
|
30
|
+
},
|
31
|
+
processId: this.processId
|
28
32
|
})
|
29
33
|
return promise
|
30
34
|
}
|
package/src/service.ts
CHANGED
@@ -5,6 +5,7 @@ import { withAbort } from 'ix/Ix.dom.asynciterable.operators.js'
|
|
5
5
|
|
6
6
|
import {
|
7
7
|
DataBinding,
|
8
|
+
DeepPartial,
|
8
9
|
Empty,
|
9
10
|
HandlerType,
|
10
11
|
ProcessBindingResponse,
|
@@ -14,6 +15,7 @@ import {
|
|
14
15
|
ProcessorServiceImplementation,
|
15
16
|
ProcessResult,
|
16
17
|
ProcessStreamRequest,
|
18
|
+
ProcessStreamResponse,
|
17
19
|
StartRequest
|
18
20
|
} from '@sentio/protos'
|
19
21
|
|
@@ -22,6 +24,8 @@ import { errorString, mergeProcessResults } from './utils.js'
|
|
22
24
|
import { freezeGlobalConfig, GLOBAL_CONFIG } from './global-config.js'
|
23
25
|
|
24
26
|
import { StoreContext } from './db-context.js'
|
27
|
+
import { Subject } from 'rxjs'
|
28
|
+
|
25
29
|
;(BigInt.prototype as any).toJSON = function () {
|
26
30
|
return this.toString()
|
27
31
|
}
|
@@ -162,38 +166,44 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
162
166
|
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')
|
163
167
|
}
|
164
168
|
|
165
|
-
const
|
169
|
+
const subject = new Subject<DeepPartial<ProcessStreamResponse>>()
|
170
|
+
const contexts: Record<number, StoreContext> = {}
|
166
171
|
new Promise(async (resolve, reject) => {
|
167
172
|
for await (const request of requests) {
|
168
173
|
if (request.binding) {
|
169
174
|
const binding = request.binding
|
175
|
+
const dbContext = new StoreContext(subject, request.processId)
|
176
|
+
contexts[request.processId] = dbContext
|
170
177
|
PluginManager.INSTANCE.processBinding(binding, dbContext)
|
171
178
|
.then((result) => {
|
172
|
-
|
179
|
+
subject.next({
|
173
180
|
result,
|
174
181
|
processId: request.processId
|
175
182
|
})
|
176
|
-
// dbContext.subject.complete()
|
177
183
|
recordRuntimeInfo(result, binding.handlerType)
|
178
184
|
})
|
179
185
|
.catch((e) => {
|
180
186
|
dbContext.error(request.processId, e)
|
181
187
|
})
|
188
|
+
.finally(() => {
|
189
|
+
delete contexts[request.processId]
|
190
|
+
})
|
182
191
|
}
|
183
192
|
if (request.dbResult) {
|
184
|
-
dbContext
|
193
|
+
const dbContext = contexts[request.processId]
|
194
|
+
dbContext?.result(request.dbResult)
|
185
195
|
}
|
186
196
|
}
|
187
197
|
resolve(null)
|
188
198
|
})
|
189
199
|
.then(() => {
|
190
|
-
|
200
|
+
subject.complete()
|
191
201
|
})
|
192
202
|
.catch((e) => {
|
193
203
|
// should not happen
|
194
|
-
|
204
|
+
subject.error(e)
|
195
205
|
})
|
196
|
-
yield* from(
|
206
|
+
yield* from(subject).pipe(withAbort(context.signal))
|
197
207
|
}
|
198
208
|
}
|
199
209
|
|