@sentio/runtime 2.6.3 → 2.6.4-rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ import { register as globalRegistry, Registry } from 'prom-client';
10
10
  import { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus';
11
11
  import http from 'http';
12
12
  const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry]);
13
- import { ProcessorDefinition } from '@sentio/protos';
13
+ import { ProcessorDefinition } from './gen/processor/protos/processor.js';
14
14
  import { ProcessorServiceImpl } from './service.js';
15
15
  import { Endpoints } from './endpoints.js';
16
16
  import { FullProcessorServiceImpl } from './full-service.js';
@@ -1 +1 @@
1
- {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAA;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,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\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { compressionAlgorithms } from '@grpc/grpc-js'\n\nimport { register as globalRegistry, Registry } from 'prom-client'\nimport { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus'\nimport http from 'http'\n\nconst mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])\n\nimport { ProcessorDefinition } from '@sentio/protos'\nimport { ProcessorServiceImpl } from './service.js'\nimport { Endpoints } from './endpoints.js'\n\nimport { FullProcessorServiceImpl } from './full-service.js'\nimport { ChainConfig } from './chain-config.js'\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n // { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nEndpoints.INSTANCE.concurrency = options.concurrency\nEndpoints.INSTANCE.chainQueryAPI = options['chainquery-server']\nEndpoints.INSTANCE.priceFeedAPI = options['pricefeed-server']\n\nfor (const [id, config] of Object.entries(chainsConfig)) {\n const chainConfig = config as ChainConfig\n if (chainConfig.ChainServer) {\n Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)\n } else {\n const http = chainConfig.Https?.[0]\n if (http) {\n Endpoints.INSTANCE.chainServer.set(id, http)\n } else {\n console.error('not valid config for chain', id)\n }\n }\n}\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': compressionAlgorithms.gzip,\n}).use(prometheusServerMiddleware())\n\nconst baseService = new ProcessorServiceImpl(async () => {\n const m = await import(options.target)\n if (options.debug) {\n console.log('Module loaded', m)\n }\n return m\n}, server.shutdown)\nconst service = new FullProcessorServiceImpl(baseService)\n\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started at:', options.port)\n\nconst metricsPort = 4040\nhttp\n .createServer(async function (req, res) {\n if (req.url && new URL(req.url, `http://${req.headers.host}`).pathname === '/metrics') {\n const metrics = await mergedRegistry.metrics()\n res.write(metrics)\n } else {\n res.writeHead(404)\n }\n res.end()\n })\n .listen(metricsPort)\n\nconsole.log('Metric Server Started at:', metricsPort)\n"]}
1
+ {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";AAEA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAA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C,IAAI,CAAC,CAAA;AAEzD,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,IAAI;KACD,YAAY,CAAC,KAAK,WAAW,GAAG,EAAE,GAAG;IACpC,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,KAAK,UAAU,EAAE;QACrF,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;QAC9C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;KACnB;SAAM;QACL,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KACnB;IACD,GAAG,CAAC,GAAG,EAAE,CAAA;AACX,CAAC,CAAC;KACD,MAAM,CAAC,WAAW,CAAC,CAAA;AAEtB,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { compressionAlgorithms } from '@grpc/grpc-js'\n\nimport { register as globalRegistry, Registry } from 'prom-client'\nimport { registry as niceGrpcRegistry, prometheusServerMiddleware } from 'nice-grpc-prometheus'\nimport http from 'http'\n\nconst mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])\n\nimport { ProcessorDefinition } from './gen/processor/protos/processor.js'\nimport { ProcessorServiceImpl } from './service.js'\nimport { Endpoints } from './endpoints.js'\n\nimport { FullProcessorServiceImpl } from './full-service.js'\nimport { ChainConfig } from './chain-config.js'\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n // { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nEndpoints.INSTANCE.concurrency = options.concurrency\nEndpoints.INSTANCE.chainQueryAPI = options['chainquery-server']\nEndpoints.INSTANCE.priceFeedAPI = options['pricefeed-server']\n\nfor (const [id, config] of Object.entries(chainsConfig)) {\n const chainConfig = config as ChainConfig\n if (chainConfig.ChainServer) {\n Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)\n } else {\n const http = chainConfig.Https?.[0]\n if (http) {\n Endpoints.INSTANCE.chainServer.set(id, http)\n } else {\n console.error('not valid config for chain', id)\n }\n }\n}\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': compressionAlgorithms.gzip,\n}).use(prometheusServerMiddleware())\n\nconst baseService = new ProcessorServiceImpl(async () => {\n const m = await import(options.target)\n if (options.debug) {\n console.log('Module loaded', m)\n }\n return m\n}, server.shutdown)\nconst service = new FullProcessorServiceImpl(baseService)\n\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started at:', options.port)\n\nconst metricsPort = 4040\nhttp\n .createServer(async function (req, res) {\n if (req.url && new URL(req.url, `http://${req.headers.host}`).pathname === '/metrics') {\n const metrics = await mergedRegistry.metrics()\n res.write(metrics)\n } else {\n res.writeHead(404)\n }\n res.end()\n })\n .listen(metricsPort)\n\nconsole.log('Metric Server Started at:', metricsPort)\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
3
  "license": "Apache-2.0",
4
- "version": "2.6.3",
4
+ "version": "2.6.4-rc.2",
5
5
  "scripts": {
6
6
  "compile": "tsc",
7
7
  "build": "yarn compile",
@@ -13,7 +13,7 @@
13
13
  "start_js": "ts-node-esm --files ./lib/processor-runner.js $PWD/../../debug/dist/lib.js"
14
14
  },
15
15
  "dependencies": {
16
- "@sentio/protos": "^2.6.3",
16
+ "@sentio/protos": "^2.6.4-rc.2",
17
17
  "command-line-args": "^5.2.1",
18
18
  "command-line-usage": "^6.1.3",
19
19
  "fs-extra": "^11.0.0",
@@ -45,5 +45,5 @@
45
45
  "!{lib,src}/tests",
46
46
  "!**/*.test.{js,ts}"
47
47
  ],
48
- "gitHead": "017cdf62e71b26978122dcbb58a090752ccf89f8"
48
+ "gitHead": "faae824002e6280c132fd607096b80e7025768c4"
49
49
  }
@@ -15,7 +15,7 @@ import http from 'http'
15
15
 
16
16
  const mergedRegistry = Registry.merge([globalRegistry, niceGrpcRegistry])
17
17
 
18
- import { ProcessorDefinition } from '@sentio/protos'
18
+ import { ProcessorDefinition } from './gen/processor/protos/processor.js'
19
19
  import { ProcessorServiceImpl } from './service.js'
20
20
  import { Endpoints } from './endpoints.js'
21
21