@sentio/runtime 3.0.0-rc.8 → 3.0.0-rc.9
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/{chunk-6MZJOWMH.js → chunk-4FNYVNIX.js} +5 -4
- package/lib/{chunk-6MZJOWMH.js.map → chunk-4FNYVNIX.js.map} +1 -1
- package/lib/{chunk-QHFSZVR5.js → chunk-ROBPWJIE.js} +36 -21
- package/lib/chunk-ROBPWJIE.js.map +1 -0
- package/lib/index.d.ts +4 -9
- package/lib/index.js +71 -10
- package/lib/index.js.map +1 -1
- package/lib/{processor-CNHsQeJ6.d.ts → processor-BUTmbpmJ.d.ts} +2 -3
- package/lib/processor-runner.js +2 -10
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +2 -2
- package/lib/test-processor.test.d.ts +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +4 -3
- package/src/gen/processor/protos/processor.ts +17 -1
- package/src/gen/service/common/protos/common.ts +356 -1
- package/src/plugin.ts +0 -11
- package/src/service-manager.ts +0 -8
- package/src/state.ts +0 -22
- package/lib/chunk-N3VEKOPD.js +0 -97
- package/lib/chunk-N3VEKOPD.js.map +0 -1
- package/lib/chunk-QHFSZVR5.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as StoreContext, E as ExecutionConfig } from './processor-
|
|
2
|
-
export { A as AbstractStoreContext, d as DataBindingContext, c as IDataBindingContext, I as IStoreContext, P as Plugin, b as PluginManager, t as timeoutError } from './processor-
|
|
1
|
+
import { S as StoreContext, E as ExecutionConfig } from './processor-BUTmbpmJ.js';
|
|
2
|
+
export { A as AbstractStoreContext, d as DataBindingContext, c as IDataBindingContext, I as IStoreContext, P as Plugin, b as PluginManager, t as timeoutError } from './processor-BUTmbpmJ.js';
|
|
3
3
|
import * as _sentio_protos from '@sentio/protos';
|
|
4
|
-
import {
|
|
4
|
+
import { ProcessResult, EthCallParam, ProcessorServiceImplementation, ProcessConfigRequest, ProcessConfigResponse, StartRequest, Empty, ProcessBindingsRequest, ProcessBindingResponse, DataBinding, PreparedData, PreprocessResult, ProcessStreamRequest, HandlerType, PreprocessStreamRequest, DeepPartial, PreprocessStreamResponse, ProcessStreamResponse } from '@sentio/protos';
|
|
5
5
|
import { Required } from 'utility-types';
|
|
6
6
|
import { CallContext } from 'nice-grpc';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
@@ -36,11 +36,6 @@ declare abstract class ListStateStorage<T> extends StateStorage<T[]> {
|
|
|
36
36
|
getValues(): T[];
|
|
37
37
|
addValue(value: T): T;
|
|
38
38
|
}
|
|
39
|
-
declare class TemplateInstanceState extends ListStateStorage<TemplateInstance> {
|
|
40
|
-
static INSTANCE: TemplateInstanceState;
|
|
41
|
-
constructor();
|
|
42
|
-
addValue(value: TemplateInstance): TemplateInstance;
|
|
43
|
-
}
|
|
44
39
|
|
|
45
40
|
declare function mergeProcessResults(results: ProcessResult[]): Required<ProcessResult, 'states'>;
|
|
46
41
|
declare function mergeProcessResultsInPlace(res: ProcessResult, results: ProcessResult[]): Required<ProcessResult, 'states'>;
|
|
@@ -867,4 +862,4 @@ declare const processMetrics: {
|
|
|
867
862
|
};
|
|
868
863
|
declare const metricsStorage: AsyncLocalStorage<string>;
|
|
869
864
|
|
|
870
|
-
export { type ChainConfig, DummyProvider, Endpoints, GLOBAL_CONFIG, type GlobalConfig, ListStateStorage, MapStateStorage, ProcessorServiceImpl, QueuedStaticJsonRpcProvider, type Semver, State, StateStorage, StoreContext,
|
|
865
|
+
export { type ChainConfig, DummyProvider, Endpoints, GLOBAL_CONFIG, type GlobalConfig, ListStateStorage, MapStateStorage, ProcessorServiceImpl, QueuedStaticJsonRpcProvider, type Semver, State, StateStorage, StoreContext, USER_PROCESSOR, compareSemver, configureEndpoints, dbMetrics, errorString, getProvider, makeEthCallKey, mergeProcessResults, mergeProcessResultsInPlace, metricsStorage, parseSemver, processMetrics, providerMetrics, recordRuntimeInfo };
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ListStateStorage,
|
|
4
|
-
MapStateStorage,
|
|
5
|
-
State,
|
|
6
|
-
StateStorage,
|
|
7
|
-
TemplateInstanceState
|
|
8
|
-
} from "./chunk-N3VEKOPD.js";
|
|
9
2
|
import {
|
|
10
3
|
AbstractStoreContext,
|
|
11
4
|
DataBindingContext,
|
|
@@ -30,14 +23,83 @@ import {
|
|
|
30
23
|
providerMetrics,
|
|
31
24
|
recordRuntimeInfo,
|
|
32
25
|
timeoutError
|
|
33
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4FNYVNIX.js";
|
|
34
27
|
import {
|
|
35
28
|
Plugin,
|
|
36
29
|
PluginManager
|
|
37
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ROBPWJIE.js";
|
|
38
31
|
import "./chunk-MV6JXS2P.js";
|
|
39
32
|
import "./chunk-KVSDPGUI.js";
|
|
40
33
|
|
|
34
|
+
// src/state.ts
|
|
35
|
+
var State = class _State {
|
|
36
|
+
stateMap = /* @__PURE__ */ new Map();
|
|
37
|
+
static INSTANCE = new _State();
|
|
38
|
+
static reset() {
|
|
39
|
+
_State.INSTANCE = new _State();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var StateStorage = class {
|
|
43
|
+
// TODO learn how to define single instance for all subclasses
|
|
44
|
+
constructor() {
|
|
45
|
+
}
|
|
46
|
+
key() {
|
|
47
|
+
return this.constructor.name;
|
|
48
|
+
}
|
|
49
|
+
getOrRegister() {
|
|
50
|
+
let metricState = State.INSTANCE.stateMap.get(this.key());
|
|
51
|
+
if (!metricState) {
|
|
52
|
+
metricState = this.initValue();
|
|
53
|
+
State.INSTANCE.stateMap.set(this.key(), metricState);
|
|
54
|
+
}
|
|
55
|
+
return metricState;
|
|
56
|
+
}
|
|
57
|
+
unregister() {
|
|
58
|
+
const value = State.INSTANCE.stateMap.get(this.key());
|
|
59
|
+
State.INSTANCE.stateMap.delete(this.key());
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var MapStateStorage = class extends StateStorage {
|
|
64
|
+
initValue() {
|
|
65
|
+
return /* @__PURE__ */ new Map();
|
|
66
|
+
}
|
|
67
|
+
getValue(key) {
|
|
68
|
+
const m = this.getOrRegister();
|
|
69
|
+
return m.get(key);
|
|
70
|
+
}
|
|
71
|
+
getValues() {
|
|
72
|
+
const m = this.getOrRegister();
|
|
73
|
+
return Array.from(m.values());
|
|
74
|
+
}
|
|
75
|
+
getOrSetValue(key, value) {
|
|
76
|
+
const m = this.getOrRegister();
|
|
77
|
+
const oldValue = m.get(key);
|
|
78
|
+
if (oldValue) {
|
|
79
|
+
if (oldValue !== value) {
|
|
80
|
+
console.warn(key, "has been registered twice, use the previous one");
|
|
81
|
+
}
|
|
82
|
+
return oldValue;
|
|
83
|
+
}
|
|
84
|
+
m.set(key, value);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var ListStateStorage = class extends StateStorage {
|
|
89
|
+
initValue() {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
getValues() {
|
|
93
|
+
return this.getOrRegister();
|
|
94
|
+
}
|
|
95
|
+
addValue(value) {
|
|
96
|
+
const m = this.getOrRegister();
|
|
97
|
+
m.push(value);
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
import("node:process").then((p) => p.stdout.write(""));
|
|
102
|
+
|
|
41
103
|
// src/chain-config.ts
|
|
42
104
|
import("node:process").then((p) => p.stdout.write(""));
|
|
43
105
|
|
|
@@ -58,7 +120,6 @@ export {
|
|
|
58
120
|
State,
|
|
59
121
|
StateStorage,
|
|
60
122
|
StoreContext,
|
|
61
|
-
TemplateInstanceState,
|
|
62
123
|
USER_PROCESSOR,
|
|
63
124
|
compareSemver,
|
|
64
125
|
configureEndpoints,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chain-config.ts","../src/index.ts"],"sourcesContent":["export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/state.ts","../src/chain-config.ts","../src/index.ts"],"sourcesContent":["export class State {\n stateMap = new Map<string, any>()\n\n static INSTANCE = new State()\n\n static reset() {\n State.INSTANCE = new State()\n }\n}\n\nexport abstract class StateStorage<T> {\n // TODO learn how to define single instance for all subclasses\n\n protected constructor() {\n //\n }\n\n abstract initValue(): T\n\n key(): string {\n return this.constructor.name\n }\n\n getOrRegister(): T {\n let metricState: T = State.INSTANCE.stateMap.get(this.key())\n if (!metricState) {\n metricState = this.initValue()\n State.INSTANCE.stateMap.set(this.key(), metricState)\n }\n return metricState\n }\n\n unregister(): T {\n const value = State.INSTANCE.stateMap.get(this.key())\n State.INSTANCE.stateMap.delete(this.key())\n return value\n }\n}\n\nexport abstract class MapStateStorage<T> extends StateStorage<Map<string, T>> {\n initValue() {\n return new Map<string, T>()\n }\n\n getValue(key: string): T | undefined {\n const m = this.getOrRegister()\n return m.get(key)\n }\n\n getValues(): T[] {\n const m = this.getOrRegister()\n return Array.from(m.values())\n }\n\n getOrSetValue(key: string, value: T): T {\n const m = this.getOrRegister()\n const oldValue = m.get(key)\n if (oldValue) {\n if (oldValue !== value) {\n console.warn(key, 'has been registered twice, use the previous one')\n }\n return oldValue\n }\n m.set(key, value)\n return value\n }\n}\n\nexport abstract class ListStateStorage<T> extends StateStorage<T[]> {\n initValue() {\n return []\n }\n\n getValues(): T[] {\n return this.getOrRegister()\n }\n\n addValue(value: T): T {\n const m = this.getOrRegister()\n m.push(value)\n return value\n }\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,QAAN,MAAM,OAAM;AAAA,EACjB,WAAW,oBAAI,IAAiB;AAAA,EAEhC,OAAO,WAAW,IAAI,OAAM;AAAA,EAE5B,OAAO,QAAQ;AACb,WAAM,WAAW,IAAI,OAAM;AAAA,EAC7B;AACF;AAEO,IAAe,eAAf,MAA+B;AAAA;AAAA,EAG1B,cAAc;AAAA,EAExB;AAAA,EAIA,MAAc;AACZ,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEA,gBAAmB;AACjB,QAAI,cAAiB,MAAM,SAAS,SAAS,IAAI,KAAK,IAAI,CAAC;AAC3D,QAAI,CAAC,aAAa;AAChB,oBAAc,KAAK,UAAU;AAC7B,YAAM,SAAS,SAAS,IAAI,KAAK,IAAI,GAAG,WAAW;AAAA,IACrD;AACA,WAAO;AAAA,EACT;AAAA,EAEA,aAAgB;AACd,UAAM,QAAQ,MAAM,SAAS,SAAS,IAAI,KAAK,IAAI,CAAC;AACpD,UAAM,SAAS,SAAS,OAAO,KAAK,IAAI,CAAC;AACzC,WAAO;AAAA,EACT;AACF;AAEO,IAAe,kBAAf,cAA0C,aAA6B;AAAA,EAC5E,YAAY;AACV,WAAO,oBAAI,IAAe;AAAA,EAC5B;AAAA,EAEA,SAAS,KAA4B;AACnC,UAAM,IAAI,KAAK,cAAc;AAC7B,WAAO,EAAE,IAAI,GAAG;AAAA,EAClB;AAAA,EAEA,YAAiB;AACf,UAAM,IAAI,KAAK,cAAc;AAC7B,WAAO,MAAM,KAAK,EAAE,OAAO,CAAC;AAAA,EAC9B;AAAA,EAEA,cAAc,KAAa,OAAa;AACtC,UAAM,IAAI,KAAK,cAAc;AAC7B,UAAM,WAAW,EAAE,IAAI,GAAG;AAC1B,QAAI,UAAU;AACZ,UAAI,aAAa,OAAO;AACtB,gBAAQ,KAAK,KAAK,iDAAiD;AAAA,MACrE;AACA,aAAO;AAAA,IACT;AACA,MAAE,IAAI,KAAK,KAAK;AAChB,WAAO;AAAA,EACT;AACF;AAEO,IAAe,mBAAf,cAA2C,aAAkB;AAAA,EAClE,YAAY;AACV,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,YAAiB;AACf,WAAO,KAAK,cAAc;AAAA,EAC5B;AAAA,EAEA,SAAS,OAAa;AACpB,UAAM,IAAI,KAAK,cAAc;AAC7B,MAAE,KAAK,KAAK;AACZ,WAAO;AAAA,EACT;AACF;AACC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;AC9ErD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACKrD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
|
@@ -13,7 +13,7 @@ interface IStoreContext {
|
|
|
13
13
|
close(): void;
|
|
14
14
|
}
|
|
15
15
|
interface IDataBindingContext extends IStoreContext {
|
|
16
|
-
sendTemplateRequest(templates: Array<TemplateInstance
|
|
16
|
+
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean): void;
|
|
17
17
|
sendTimeseriesRequest(timeseries: Array<TimeseriesResult$1>): void;
|
|
18
18
|
}
|
|
19
19
|
declare abstract class AbstractStoreContext implements IStoreContext {
|
|
@@ -52,7 +52,7 @@ declare class DataBindingContext extends AbstractStoreContext implements IDataBi
|
|
|
52
52
|
readonly processId: number;
|
|
53
53
|
readonly subject: Subject<DeepPartial$2<ProcessStreamResponseV3>>;
|
|
54
54
|
constructor(processId: number, subject: Subject<DeepPartial$2<ProcessStreamResponseV3>>);
|
|
55
|
-
sendTemplateRequest(templates: Array<TemplateInstance
|
|
55
|
+
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean): void;
|
|
56
56
|
sendTimeseriesRequest(timeseries: Array<TimeseriesResult$1>): void;
|
|
57
57
|
doSend(resp: DeepPartial$2<ProcessStreamResponseV3>): void;
|
|
58
58
|
}
|
|
@@ -101,7 +101,6 @@ declare class PluginManager {
|
|
|
101
101
|
[k: string]: any;
|
|
102
102
|
}, dbContext?: IDataBindingContext | IStoreContext): Promise<PreprocessResult>;
|
|
103
103
|
updateTemplates(request: UpdateTemplatesRequest): Promise<void>;
|
|
104
|
-
sendTemplateInstance(instance: TemplateInstance): void;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
declare enum RichValue_NullValue {
|
package/lib/processor-runner.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
TemplateInstanceState
|
|
5
|
-
} from "./chunk-N3VEKOPD.js";
|
|
6
3
|
import {
|
|
7
4
|
require_ms,
|
|
8
5
|
setupLogger
|
|
@@ -29,7 +26,7 @@ import {
|
|
|
29
26
|
require_lib4,
|
|
30
27
|
require_src,
|
|
31
28
|
withAbort
|
|
32
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-4FNYVNIX.js";
|
|
33
30
|
import {
|
|
34
31
|
ExecutionConfig,
|
|
35
32
|
HandlerType,
|
|
@@ -40,7 +37,7 @@ import {
|
|
|
40
37
|
ProcessorV3Definition,
|
|
41
38
|
StartRequest,
|
|
42
39
|
require_minimal2 as require_minimal
|
|
43
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ROBPWJIE.js";
|
|
44
41
|
import {
|
|
45
42
|
DiagConsoleLogger,
|
|
46
43
|
DiagLogLevel,
|
|
@@ -32542,11 +32539,6 @@ var ServiceManager = class extends ProcessorServiceImpl {
|
|
|
32542
32539
|
argv: process.argv,
|
|
32543
32540
|
workerData: this.workerData
|
|
32544
32541
|
});
|
|
32545
|
-
this.pool.on("message", (msg) => {
|
|
32546
|
-
if (msg.event == "add_template_instance") {
|
|
32547
|
-
TemplateInstanceState.INSTANCE.addValue(msg.value);
|
|
32548
|
-
}
|
|
32549
|
-
});
|
|
32550
32542
|
}
|
|
32551
32543
|
};
|
|
32552
32544
|
var Contexts = class {
|