@sentio/runtime 2.36.2-rc.1 → 2.37.0-rc.3
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 +140 -0
- package/lib/db-context.d.ts.map +1 -0
- package/lib/db-context.js +36 -0
- package/lib/db-context.js.map +1 -0
- package/lib/full-service.d.ts +156 -2
- package/lib/full-service.d.ts.map +1 -1
- package/lib/full-service.js +2 -2
- package/lib/full-service.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +134 -14
- package/lib/gen/processor/protos/processor.d.ts.map +1 -1
- package/lib/gen/processor/protos/processor.js +731 -2
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/plugin.d.ts +5 -1
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +6 -2
- package/lib/plugin.js.map +1 -1
- package/lib/service.d.ts +129 -5
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +29 -12
- package/lib/service.js.map +1 -1
- package/package.json +4 -2
- package/src/db-context.ts +43 -0
- package/src/full-service.ts +4 -3
- package/src/gen/processor/protos/processor.ts +1015 -153
- package/src/index.ts +1 -0
- package/src/plugin.ts +8 -2
- package/src/service.ts +34 -15
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACrE,cAAc,iBAAiB,CAAA"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA;AACrE,cAAc,iBAAiB,CAAA"}
|
package/lib/plugin.d.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
1
2
|
import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult, StartRequest } from '@sentio/protos';
|
3
|
+
import { StoreContext } from './db-context.js';
|
4
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
2
5
|
export declare abstract class Plugin {
|
3
6
|
name: string;
|
4
7
|
supportedHandlers: HandlerType[];
|
@@ -12,6 +15,7 @@ export declare abstract class Plugin {
|
|
12
15
|
}
|
13
16
|
export declare class PluginManager {
|
14
17
|
static INSTANCE: PluginManager;
|
18
|
+
dbContextLocalStorage: AsyncLocalStorage<StoreContext | undefined>;
|
15
19
|
plugins: Plugin[];
|
16
20
|
typesToPlugin: Map<HandlerType, Plugin>;
|
17
21
|
register(plugin: Plugin): void;
|
@@ -21,6 +25,6 @@ export declare class PluginManager {
|
|
21
25
|
* @deprecated The method should not be used, use ctx.states instead
|
22
26
|
*/
|
23
27
|
stateDiff(config: ProcessConfigResponse): boolean;
|
24
|
-
processBinding(request: DataBinding): Promise<ProcessResult>;
|
28
|
+
processBinding(request: DataBinding, dbContext?: StoreContext): Promise<ProcessResult>;
|
25
29
|
}
|
26
30
|
//# sourceMappingURL=plugin.d.ts.map
|
package/lib/plugin.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,8BAAsB,MAAM;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,EAAE,WAAW,EAAE,CAAK;IAE/B,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IACvD,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAE/C;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO;IAI3C,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAGnE;AAED,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,gBAAsB;IAErC,qBAAqB,8CAAoD;IACzE,OAAO,EAAE,MAAM,EAAE,CAAK;IACtB,aAAa,2BAAiC;IAE9C,QAAQ,CAAC,MAAM,EAAE,MAAM;IAevB,SAAS,CAAC,MAAM,EAAE,qBAAqB;IAIvC,KAAK,CAAC,KAAK,EAAE,YAAY;IAIzB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO;IAIjD,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CASvF"}
|
package/lib/plugin.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { ProcessResult } from '@sentio/protos';
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
2
3
|
export class Plugin {
|
3
4
|
name;
|
4
5
|
supportedHandlers = [];
|
@@ -16,6 +17,7 @@ export class Plugin {
|
|
16
17
|
}
|
17
18
|
export class PluginManager {
|
18
19
|
static INSTANCE = new PluginManager();
|
20
|
+
dbContextLocalStorage = new AsyncLocalStorage();
|
19
21
|
plugins = [];
|
20
22
|
typesToPlugin = new Map();
|
21
23
|
register(plugin) {
|
@@ -43,12 +45,14 @@ export class PluginManager {
|
|
43
45
|
stateDiff(config) {
|
44
46
|
return this.plugins.some((plugin) => plugin.stateDiff(config));
|
45
47
|
}
|
46
|
-
processBinding(request) {
|
48
|
+
processBinding(request, dbContext) {
|
47
49
|
const plugin = this.typesToPlugin.get(request.handlerType);
|
48
50
|
if (!plugin) {
|
49
51
|
throw new Error(`No plugin for ${request.handlerType}`);
|
50
52
|
}
|
51
|
-
return
|
53
|
+
return this.dbContextLocalStorage.run(dbContext, () => {
|
54
|
+
return plugin.processBinding(request);
|
55
|
+
});
|
52
56
|
}
|
53
57
|
}
|
54
58
|
//# sourceMappingURL=plugin.js.map
|
package/lib/plugin.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAE7G,MAAM,OAAgB,MAAM;IAC1B,IAAI,CAAQ;IACZ,iBAAiB,GAAkB,EAAE,CAAA;IAErC,KAAK,CAAC,SAAS,CAAC,MAA6B,IAAkB,CAAC;IAChE,KAAK,CAAC,KAAK,CAAC,KAAmB,IAAkB,CAAC;IAElD;;OAEG;IACH,SAAS,CAAC,MAA6B;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,aAAa,EAAgB,MAAM,gBAAgB,CAAA;AAE7G,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,MAAM,OAAgB,MAAM;IAC1B,IAAI,CAAQ;IACZ,iBAAiB,GAAkB,EAAE,CAAA;IAErC,KAAK,CAAC,SAAS,CAAC,MAA6B,IAAkB,CAAC;IAChE,KAAK,CAAC,KAAK,CAAC,KAAmB,IAAkB,CAAC;IAElD;;OAEG;IACH,SAAS,CAAC,MAA6B;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAoB;QACvC,OAAO,aAAa,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IACxB,MAAM,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAA;IAErC,qBAAqB,GAAG,IAAI,iBAAiB,EAA4B,CAAA;IACzE,OAAO,GAAa,EAAE,CAAA;IACtB,aAAa,GAAG,IA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c,CAAC,OAAoB,EAAE,SAAwB;QAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;QACzD,CAAC;QACD,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE;YACpD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC"}
|
package/lib/service.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { CallContext } from 'nice-grpc';
|
2
|
-
import { DataBinding, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, ProcessResult,
|
2
|
+
import { DataBinding, Empty, HandlerType, ProcessBindingResponse, ProcessBindingsRequest, ProcessConfigRequest, ProcessConfigResponse, ProcessorServiceImplementation, ProcessResult, ProcessStreamRequest, StartRequest } from '@sentio/protos';
|
3
3
|
export declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
4
4
|
private started;
|
5
5
|
unhandled: Error;
|
@@ -11,9 +11,133 @@ export declare class ProcessorServiceImpl implements ProcessorServiceImplementat
|
|
11
11
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
12
12
|
processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse>;
|
13
13
|
processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult>;
|
14
|
-
processBindingsStream(requests: AsyncIterable<
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext): AsyncGenerator<{
|
15
|
+
processId?: number | undefined;
|
16
|
+
dbRequest?: {
|
17
|
+
opId?: bigint | undefined;
|
18
|
+
get?: {
|
19
|
+
entity?: string | undefined;
|
20
|
+
id?: string | undefined;
|
21
|
+
} | undefined;
|
22
|
+
upsert?: {
|
23
|
+
entity?: string | undefined;
|
24
|
+
id?: string[] | undefined;
|
25
|
+
data?: {
|
26
|
+
[x: string]: any;
|
27
|
+
}[] | undefined;
|
28
|
+
} | undefined;
|
29
|
+
delete?: {
|
30
|
+
entity?: string | undefined;
|
31
|
+
id?: string[] | undefined;
|
32
|
+
} | undefined;
|
33
|
+
list?: {
|
34
|
+
entity?: string | undefined;
|
35
|
+
limit?: number | undefined;
|
36
|
+
offset?: number | undefined;
|
37
|
+
} | undefined;
|
38
|
+
} | undefined;
|
39
|
+
result?: {
|
40
|
+
gauges?: {
|
41
|
+
metadata?: {
|
42
|
+
address?: string | undefined;
|
43
|
+
contractName?: string | undefined;
|
44
|
+
blockNumber?: bigint | undefined;
|
45
|
+
transactionHash?: string | undefined;
|
46
|
+
chainId?: string | undefined;
|
47
|
+
transactionIndex?: number | undefined;
|
48
|
+
logIndex?: number | undefined;
|
49
|
+
name?: string | undefined;
|
50
|
+
labels?: {
|
51
|
+
[x: string]: string | undefined;
|
52
|
+
} | undefined;
|
53
|
+
} | undefined;
|
54
|
+
metricValue?: {
|
55
|
+
bigDecimal?: string | undefined;
|
56
|
+
doubleValue?: number | undefined;
|
57
|
+
bigInteger?: {
|
58
|
+
negative?: boolean | undefined;
|
59
|
+
data?: Uint8Array | undefined;
|
60
|
+
} | undefined;
|
61
|
+
} | undefined;
|
62
|
+
runtimeInfo?: {
|
63
|
+
from?: HandlerType | undefined;
|
64
|
+
} | undefined;
|
65
|
+
}[] | undefined;
|
66
|
+
counters?: {
|
67
|
+
metadata?: {
|
68
|
+
address?: string | undefined;
|
69
|
+
contractName?: string | undefined;
|
70
|
+
blockNumber?: bigint | undefined;
|
71
|
+
transactionHash?: string | undefined;
|
72
|
+
chainId?: string | undefined;
|
73
|
+
transactionIndex?: number | undefined;
|
74
|
+
logIndex?: number | undefined;
|
75
|
+
name?: string | undefined;
|
76
|
+
labels?: {
|
77
|
+
[x: string]: string | undefined;
|
78
|
+
} | undefined;
|
79
|
+
} | undefined;
|
80
|
+
metricValue?: {
|
81
|
+
bigDecimal?: string | undefined;
|
82
|
+
doubleValue?: number | undefined;
|
83
|
+
bigInteger?: {
|
84
|
+
negative?: boolean | undefined;
|
85
|
+
data?: Uint8Array | undefined;
|
86
|
+
} | undefined;
|
87
|
+
} | undefined;
|
88
|
+
add?: boolean | undefined;
|
89
|
+
runtimeInfo?: {
|
90
|
+
from?: HandlerType | undefined;
|
91
|
+
} | undefined;
|
92
|
+
}[] | undefined;
|
93
|
+
events?: {
|
94
|
+
metadata?: {
|
95
|
+
address?: string | undefined;
|
96
|
+
contractName?: string | undefined;
|
97
|
+
blockNumber?: bigint | undefined;
|
98
|
+
transactionHash?: string | undefined;
|
99
|
+
chainId?: string | undefined;
|
100
|
+
transactionIndex?: number | undefined;
|
101
|
+
logIndex?: number | undefined;
|
102
|
+
name?: string | undefined;
|
103
|
+
labels?: {
|
104
|
+
[x: string]: string | undefined;
|
105
|
+
} | undefined;
|
106
|
+
} | undefined;
|
107
|
+
distinctEntityId?: string | undefined;
|
108
|
+
attributes?: {
|
109
|
+
[x: string]: any;
|
110
|
+
} | undefined;
|
111
|
+
severity?: import("@sentio/protos").LogLevel | undefined;
|
112
|
+
message?: string | undefined;
|
113
|
+
runtimeInfo?: {
|
114
|
+
from?: HandlerType | undefined;
|
115
|
+
} | undefined;
|
116
|
+
noMetric?: boolean | undefined;
|
117
|
+
}[] | undefined;
|
118
|
+
exports?: {
|
119
|
+
metadata?: {
|
120
|
+
address?: string | undefined;
|
121
|
+
contractName?: string | undefined;
|
122
|
+
blockNumber?: bigint | undefined;
|
123
|
+
transactionHash?: string | undefined;
|
124
|
+
chainId?: string | undefined;
|
125
|
+
transactionIndex?: number | undefined;
|
126
|
+
logIndex?: number | undefined;
|
127
|
+
name?: string | undefined;
|
128
|
+
labels?: {
|
129
|
+
[x: string]: string | undefined;
|
130
|
+
} | undefined;
|
131
|
+
} | undefined;
|
132
|
+
payload?: string | undefined;
|
133
|
+
runtimeInfo?: {
|
134
|
+
from?: HandlerType | undefined;
|
135
|
+
} | undefined;
|
136
|
+
}[] | undefined;
|
137
|
+
states?: {
|
138
|
+
configUpdated?: boolean | undefined;
|
139
|
+
} | undefined;
|
140
|
+
} | undefined;
|
141
|
+
}, void, undefined>;
|
18
142
|
}
|
19
143
|
//# sourceMappingURL=service.d.ts.map
|
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;
|
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,EACX,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,oBAAoB,EACpB,YAAY,EACb,MAAM,gBAAgB,CAAA;AAWvB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BjG"}
|
package/lib/service.js
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
import { ServerError, Status } from 'nice-grpc';
|
2
|
-
import {
|
2
|
+
import { DebugInfo, RichServerError } from 'nice-grpc-error-details';
|
3
|
+
import { from } from 'ix/Ix.dom.asynciterable.js';
|
4
|
+
import { withAbort } from 'ix/Ix.dom.asynciterable.operators.js';
|
3
5
|
import { ProcessConfigResponse } from '@sentio/protos';
|
4
6
|
import { PluginManager } from './plugin.js';
|
5
7
|
import { errorString, mergeProcessResults } from './utils.js';
|
6
8
|
import { freezeGlobalConfig, GLOBAL_CONFIG } from './global-config.js';
|
9
|
+
import { StoreContext } from './db-context.js';
|
7
10
|
BigInt.prototype.toJSON = function () {
|
8
11
|
return this.toString();
|
9
12
|
};
|
@@ -118,18 +121,32 @@ export class ProcessorServiceImpl {
|
|
118
121
|
return result;
|
119
122
|
}
|
120
123
|
async *processBindingsStream(requests, context) {
|
121
|
-
|
122
|
-
|
123
|
-
// let updated = false
|
124
|
-
// if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {
|
125
|
-
// await this.configure()
|
126
|
-
// updated = true
|
127
|
-
// }
|
128
|
-
yield {
|
129
|
-
result,
|
130
|
-
configUpdated: result.states?.configUpdated || false
|
131
|
-
};
|
124
|
+
if (!this.started) {
|
125
|
+
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.');
|
132
126
|
}
|
127
|
+
const dbContext = new StoreContext();
|
128
|
+
new Promise(async (resolve, reject) => {
|
129
|
+
for await (const request of requests) {
|
130
|
+
if (request.binding) {
|
131
|
+
const binding = request.binding;
|
132
|
+
PluginManager.INSTANCE.processBinding(binding, dbContext).then((result) => {
|
133
|
+
dbContext.subject.next({
|
134
|
+
result,
|
135
|
+
processId: request.processId
|
136
|
+
});
|
137
|
+
// dbContext.subject.complete()
|
138
|
+
recordRuntimeInfo(result, binding.handlerType);
|
139
|
+
});
|
140
|
+
}
|
141
|
+
if (request.dbResult) {
|
142
|
+
dbContext.result(request.dbResult);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
resolve(null);
|
146
|
+
}).then(() => {
|
147
|
+
dbContext.subject.complete();
|
148
|
+
});
|
149
|
+
yield* from(dbContext.subject).pipe(withAbort(context.signal));
|
133
150
|
}
|
134
151
|
}
|
135
152
|
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,eAAe,EAAE,SAAS,EAAE,MAAM,
|
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,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,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.
|
3
|
+
"version": "2.37.0-rc.3",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -20,6 +20,7 @@
|
|
20
20
|
"command-line-usage": "^7.0.1",
|
21
21
|
"fs-extra": "^11.2.0",
|
22
22
|
"google-protobuf": "^3.21.2",
|
23
|
+
"ix": "^5.0.0",
|
23
24
|
"long": "^5.2.3",
|
24
25
|
"nice-grpc": "^2.1.7",
|
25
26
|
"nice-grpc-client-middleware-retry": "^3.1.6",
|
@@ -28,9 +29,10 @@
|
|
28
29
|
"nice-grpc-prometheus": "^0.2.2",
|
29
30
|
"prom-client": "^14.2.0",
|
30
31
|
"protobufjs": "^7.2.6",
|
32
|
+
"rxjs": "^7.8.1",
|
31
33
|
"utility-types": "^3.11.0",
|
32
34
|
"winston": "^3.11.0",
|
33
|
-
"@sentio/protos": "2.
|
35
|
+
"@sentio/protos": "2.37.0-rc.3"
|
34
36
|
},
|
35
37
|
"devDependencies": {
|
36
38
|
"@types/command-line-args": "^5.2.3",
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { Subject } from 'rxjs'
|
2
|
+
import { DBRequest, DBResponse, DeepPartial, ProcessStreamResponse } from '@sentio/protos'
|
3
|
+
|
4
|
+
type Request = Omit<DBRequest, 'opId'>
|
5
|
+
|
6
|
+
export class StoreContext {
|
7
|
+
private opCounter = 0n
|
8
|
+
|
9
|
+
private defers = new Map<bigint, { resolve: (value: any) => void; reject: (reason?: any) => void }>()
|
10
|
+
|
11
|
+
subject = new Subject<DeepPartial<ProcessStreamResponse>>()
|
12
|
+
|
13
|
+
newPromise<T>(opId: bigint) {
|
14
|
+
return new Promise<T>((resolve, reject) => {
|
15
|
+
this.defers.set(opId, { resolve, reject })
|
16
|
+
})
|
17
|
+
}
|
18
|
+
|
19
|
+
sendRequest(request: DeepPartial<Request>) {
|
20
|
+
const opId = this.opCounter++
|
21
|
+
const promise = this.newPromise(opId)
|
22
|
+
this.subject.next({
|
23
|
+
dbRequest: {
|
24
|
+
...request,
|
25
|
+
opId
|
26
|
+
}
|
27
|
+
})
|
28
|
+
return promise
|
29
|
+
}
|
30
|
+
|
31
|
+
result(dbResult: DBResponse) {
|
32
|
+
const opId = dbResult.opId
|
33
|
+
const defer = this.defers.get(opId)
|
34
|
+
if (defer) {
|
35
|
+
if (dbResult.error) {
|
36
|
+
defer.reject(dbResult.error)
|
37
|
+
} else {
|
38
|
+
defer.resolve(dbResult.data)
|
39
|
+
}
|
40
|
+
this.defers.delete(opId)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
package/src/full-service.ts
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
DataBinding,
|
8
8
|
HandlerType,
|
9
9
|
ProcessBindingsRequest,
|
10
|
+
ProcessStreamRequest,
|
10
11
|
ProcessConfigRequest,
|
11
12
|
ProcessorServiceImplementation,
|
12
13
|
StartRequest,
|
@@ -105,9 +106,9 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
105
106
|
}
|
106
107
|
}
|
107
108
|
|
108
|
-
async *processBindingsStream(requests: AsyncIterable<
|
109
|
-
throw new Error('Not Implemented for streaming')
|
110
|
-
|
109
|
+
async *processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
|
110
|
+
// throw new Error('Not Implemented for streaming')
|
111
|
+
yield* this.instance.processBindingsStream(requests, context)
|
111
112
|
}
|
112
113
|
|
113
114
|
private adjustResult(res: ProcessResult): void {}
|