@sentio/runtime 1.38.1-rc.1 → 1.38.1-rc.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/lib/plugin.js +3 -0
- package/lib/plugin.js.map +1 -1
- package/package.json +3 -3
- package/src/plugin.ts +4 -0
package/lib/plugin.js
CHANGED
@@ -20,6 +20,9 @@ class PluginManager {
|
|
20
20
|
plugins = [];
|
21
21
|
typesToPlugin = new Map();
|
22
22
|
register(plugin) {
|
23
|
+
if (this.plugins.find((p) => p.name === plugin.name)) {
|
24
|
+
return;
|
25
|
+
}
|
23
26
|
this.plugins.push(plugin);
|
24
27
|
for (const handlerType of plugin.supportedHandlers) {
|
25
28
|
const exsited = this.typesToPlugin.get(handlerType);
|
package/lib/plugin.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;AAAA,2CAA6G;AAE7G,MAAsB,MAAM;IAC1B,IAAI,CAAQ;IACZ,iBAAiB,GAAkB,EAAE,CAAA;IAErC,SAAS,CAAC,MAA6B,IAAG,CAAC;IAC3C,KAAK,CAAC,KAAmB,IAAG,CAAC;IAC7B,SAAS,CAAC,MAA6B;QACrC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,OAAoB;QACvC,OAAO,sBAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IACtC,CAAC;CACF;AAZD,wBAYC;AAED,MAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAA;IAErC,OAAO,GAAa,EAAE,CAAA;IACtB,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAA;IAE9C,QAAQ,CAAC,MAAc;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts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C,MAAM,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK,CAAC,KAAmB;QACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;IAED,SAAS,CAAC,MAA6B;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,cAAc,CAAC,OAAoB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC1D,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;SACxD;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;;AAvCH,sCAwCC","sourcesContent":["import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult, StartRequest } from '@sentio/protos'\n\nexport abstract class Plugin {\n name: string\n supportedHandlers: HandlerType[] = []\n\n configure(config: ProcessConfigResponse) {}\n start(start: StartRequest) {}\n stateDiff(config: ProcessConfigResponse): boolean {\n return false\n }\n async processBinding(request: DataBinding): Promise<ProcessResult> {\n return ProcessResult.fromPartial({})\n }\n}\n\nexport class PluginManager {\n static INSTANCE = new PluginManager()\n\n plugins: Plugin[] = []\n typesToPlugin = new Map<HandlerType, Plugin>()\n\n register(plugin: Plugin) {\n if (this.plugins.find((p) => p.name === plugin.name)) {\n return\n }\n this.plugins.push(plugin)\n\n for (const handlerType of plugin.supportedHandlers) {\n const exsited = this.typesToPlugin.get(handlerType)\n if (exsited) {\n throw new Error(`Duplicate plugin for ${handlerType}: ${exsited.name} and ${plugin.name}`)\n }\n this.typesToPlugin.set(handlerType, plugin)\n }\n }\n\n configure(config: ProcessConfigResponse) {\n this.plugins.forEach((plugin) => plugin.configure(config))\n }\n\n start(start: StartRequest) {\n this.plugins.forEach((plugin) => plugin.start(start))\n }\n\n stateDiff(config: ProcessConfigResponse): boolean {\n return this.plugins.some((plugin) => plugin.stateDiff(config))\n }\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n const plugin = this.typesToPlugin.get(request.handlerType)\n if (!plugin) {\n throw new Error(`No plugin for ${request.handlerType}`)\n }\n return plugin.processBinding(request)\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
3
|
"license": "Apache-2.0",
|
4
|
-
"version": "1.38.1-rc.
|
4
|
+
"version": "1.38.1-rc.2",
|
5
5
|
"scripts": {
|
6
6
|
"compile": "tsc -p .",
|
7
7
|
"build": "yarn compile",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"@ethersproject/providers": "~5.7.0",
|
13
|
-
"@sentio/protos": "^1.38.1-rc.
|
13
|
+
"@sentio/protos": "^1.38.1-rc.2",
|
14
14
|
"bignumber.js": "^9.1.0",
|
15
15
|
"command-line-args": "^5.2.1",
|
16
16
|
"command-line-usage": "^6.1.3",
|
@@ -46,5 +46,5 @@
|
|
46
46
|
"!{lib,src}/tests",
|
47
47
|
"!**/*.test.{js,ts}"
|
48
48
|
],
|
49
|
-
"gitHead": "
|
49
|
+
"gitHead": "a83a89be0f4a2c9440fd00cb531e25cafb4df27a"
|
50
50
|
}
|
package/src/plugin.ts
CHANGED
@@ -21,7 +21,11 @@ export class PluginManager {
|
|
21
21
|
typesToPlugin = new Map<HandlerType, Plugin>()
|
22
22
|
|
23
23
|
register(plugin: Plugin) {
|
24
|
+
if (this.plugins.find((p) => p.name === plugin.name)) {
|
25
|
+
return
|
26
|
+
}
|
24
27
|
this.plugins.push(plugin)
|
28
|
+
|
25
29
|
for (const handlerType of plugin.supportedHandlers) {
|
26
30
|
const exsited = this.typesToPlugin.get(handlerType)
|
27
31
|
if (exsited) {
|