@chainlink/external-adapter-framework 0.0.10 → 0.0.12
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/.c8rc.json +3 -0
- package/.eslintignore +9 -0
- package/.eslintrc.js +96 -0
- package/.github/README.MD +17 -0
- package/.github/actions/setup/action.yaml +13 -0
- package/.github/workflows/main.yaml +39 -0
- package/.github/workflows/publish.yaml +20 -0
- package/.prettierignore +13 -0
- package/.yarnrc +0 -0
- package/README.md +103 -0
- package/dist/src/adapter.d.ts +135 -0
- package/dist/src/adapter.js +145 -0
- package/dist/src/background-executor.d.ts +11 -0
- package/{background-executor.js → dist/src/background-executor.js} +0 -0
- package/{cache → dist/src/cache}/factory.d.ts +0 -0
- package/dist/src/cache/factory.js +55 -0
- package/dist/src/cache/index.d.ts +94 -0
- package/dist/src/cache/index.js +173 -0
- package/{cache → dist/src/cache}/local.d.ts +0 -0
- package/{cache → dist/src/cache}/local.js +0 -0
- package/{cache → dist/src/cache}/metrics.d.ts +0 -0
- package/{cache → dist/src/cache}/metrics.js +0 -0
- package/{cache → dist/src/cache}/redis.d.ts +0 -0
- package/dist/src/cache/redis.js +100 -0
- package/dist/src/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
- package/dist/src/config/index.d.ts +214 -0
- package/dist/src/config/index.js +380 -0
- package/{config → dist/src/config}/provider-limits.d.ts +0 -0
- package/{config → dist/src/config}/provider-limits.js +1 -1
- package/dist/src/examples/bank-frick/accounts.d.ts +39 -0
- package/dist/src/examples/bank-frick/accounts.js +192 -0
- package/dist/src/examples/bank-frick/config/index.d.ts +4 -0
- package/dist/src/examples/bank-frick/config/index.js +54 -0
- package/dist/src/examples/bank-frick/index.d.ts +2 -0
- package/dist/src/examples/bank-frick/index.js +15 -0
- package/dist/src/examples/bank-frick/util.d.ts +4 -0
- package/dist/src/examples/bank-frick/util.js +39 -0
- package/dist/src/examples/coingecko/batch-warming.d.ts +7 -0
- package/dist/src/examples/coingecko/batch-warming.js +53 -0
- package/dist/src/examples/coingecko/index.d.ts +2 -0
- package/dist/src/examples/coingecko/index.js +11 -0
- package/dist/src/examples/coingecko/rest.d.ts +12 -0
- package/dist/src/examples/coingecko/rest.js +51 -0
- package/{examples → dist/src/examples}/ncfx/config/index.d.ts +0 -0
- package/{examples → dist/src/examples}/ncfx/config/index.js +0 -0
- package/dist/src/examples/ncfx/index.d.ts +13 -0
- package/dist/src/examples/ncfx/index.js +11 -0
- package/dist/src/examples/ncfx/websocket.d.ts +47 -0
- package/dist/src/examples/ncfx/websocket.js +73 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +128 -0
- package/{metrics → dist/src/metrics}/constants.d.ts +0 -0
- package/{metrics → dist/src/metrics}/constants.js +0 -0
- package/{metrics → dist/src/metrics}/index.d.ts +0 -0
- package/dist/src/metrics/index.js +122 -0
- package/dist/src/metrics/util.d.ts +7 -0
- package/dist/src/metrics/util.js +9 -0
- package/{adapter.d.ts → dist/src/package/adapter.d.ts} +0 -0
- package/{adapter.js → dist/src/package/adapter.js} +0 -0
- package/{background-executor.d.ts → dist/src/package/background-executor.d.ts} +0 -0
- package/dist/src/package/background-executor.js +45 -0
- package/dist/src/package/cache/factory.d.ts +6 -0
- package/{cache → dist/src/package/cache}/factory.js +0 -0
- package/{cache → dist/src/package/cache}/index.d.ts +0 -0
- package/{cache → dist/src/package/cache}/index.js +0 -0
- package/dist/src/package/cache/local.d.ts +23 -0
- package/dist/src/package/cache/local.js +83 -0
- package/dist/src/package/cache/metrics.d.ts +27 -0
- package/dist/src/package/cache/metrics.js +120 -0
- package/dist/src/package/cache/redis.d.ts +16 -0
- package/{cache → dist/src/package/cache}/redis.js +0 -0
- package/{config → dist/src/package/config}/index.d.ts +0 -0
- package/{config → dist/src/package/config}/index.js +0 -0
- package/dist/src/package/config/provider-limits.d.ts +31 -0
- package/dist/src/package/config/provider-limits.js +76 -0
- package/{examples → dist/src/package/examples}/coingecko/batch-warming.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/batch-warming.js +0 -0
- package/{examples → dist/src/package/examples}/coingecko/index.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/index.js +0 -0
- package/{examples → dist/src/package/examples}/coingecko/rest.d.ts +0 -0
- package/{examples → dist/src/package/examples}/coingecko/rest.js +0 -0
- package/dist/src/package/examples/ncfx/config/index.d.ts +12 -0
- package/dist/src/package/examples/ncfx/config/index.js +15 -0
- package/{examples → dist/src/package/examples}/ncfx/index.d.ts +0 -0
- package/{examples → dist/src/package/examples}/ncfx/index.js +0 -0
- package/{examples → dist/src/package/examples}/ncfx/websocket.d.ts +0 -0
- package/{examples → dist/src/package/examples}/ncfx/websocket.js +0 -0
- package/{index.d.ts → dist/src/package/index.d.ts} +0 -0
- package/{index.js → dist/src/package/index.js} +0 -0
- package/dist/src/package/metrics/constants.d.ts +16 -0
- package/dist/src/package/metrics/constants.js +25 -0
- package/dist/src/package/metrics/index.d.ts +15 -0
- package/{metrics → dist/src/package/metrics}/index.js +0 -0
- package/{metrics → dist/src/package/metrics}/util.d.ts +0 -0
- package/{metrics → dist/src/package/metrics}/util.js +0 -0
- package/dist/src/package/package.json +72 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/background/fixed-frequency.d.ts +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/background/fixed-frequency.js +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/index.d.ts +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/index.js +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/metrics.d.ts +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/metrics.js +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/request/simple-counting.d.ts +0 -0
- package/{rate-limiting → dist/src/package/rate-limiting}/request/simple-counting.js +0 -0
- package/{test.d.ts → dist/src/package/test.d.ts} +0 -0
- package/{test.js → dist/src/package/test.js} +0 -0
- package/{transports → dist/src/package/transports}/batch-warming.d.ts +0 -0
- package/{transports → dist/src/package/transports}/batch-warming.js +0 -0
- package/{transports → dist/src/package/transports}/index.d.ts +0 -0
- package/{transports → dist/src/package/transports}/index.js +0 -0
- package/{transports → dist/src/package/transports}/metrics.d.ts +0 -0
- package/{transports → dist/src/package/transports}/metrics.js +0 -0
- package/{transports → dist/src/package/transports}/rest.d.ts +0 -0
- package/{transports → dist/src/package/transports}/rest.js +0 -0
- package/{transports → dist/src/package/transports}/util.d.ts +0 -0
- package/{transports → dist/src/package/transports}/util.js +0 -0
- package/{transports → dist/src/package/transports}/websocket.d.ts +0 -0
- package/{transports → dist/src/package/transports}/websocket.js +0 -0
- package/{util → dist/src/package/util}/expiring-sorted-set.d.ts +0 -0
- package/{util → dist/src/package/util}/expiring-sorted-set.js +0 -0
- package/{util → dist/src/package/util}/index.d.ts +0 -0
- package/{util → dist/src/package/util}/index.js +0 -0
- package/{util → dist/src/package/util}/logger.d.ts +0 -0
- package/{util → dist/src/package/util}/logger.js +0 -0
- package/{util → dist/src/package/util}/request.d.ts +0 -0
- package/{util → dist/src/package/util}/request.js +0 -0
- package/{validation → dist/src/package/validation}/error.d.ts +0 -0
- package/{validation → dist/src/package/validation}/error.js +0 -0
- package/{validation → dist/src/package/validation}/index.d.ts +0 -0
- package/{validation → dist/src/package/validation}/index.js +0 -0
- package/{validation → dist/src/package/validation}/input-params.d.ts +0 -0
- package/{validation → dist/src/package/validation}/input-params.js +0 -0
- package/{validation → dist/src/package/validation}/override-functions.d.ts +0 -0
- package/{validation → dist/src/package/validation}/override-functions.js +0 -0
- package/{validation → dist/src/package/validation}/preset-tokens.json +0 -0
- package/{validation → dist/src/package/validation}/validator.d.ts +0 -0
- package/{validation → dist/src/package/validation}/validator.js +0 -0
- package/dist/src/package.json +72 -0
- package/dist/src/rate-limiting/background/fixed-frequency.d.ts +11 -0
- package/dist/src/rate-limiting/background/fixed-frequency.js +35 -0
- package/dist/src/rate-limiting/index.d.ts +55 -0
- package/dist/src/rate-limiting/index.js +63 -0
- package/dist/src/rate-limiting/metrics.d.ts +3 -0
- package/dist/src/rate-limiting/metrics.js +44 -0
- package/dist/src/rate-limiting/request/simple-counting.d.ts +21 -0
- package/dist/src/rate-limiting/request/simple-counting.js +62 -0
- package/dist/src/test.d.ts +1 -0
- package/dist/src/test.js +6 -0
- package/dist/src/transports/batch-warming.d.ts +35 -0
- package/dist/src/transports/batch-warming.js +101 -0
- package/dist/src/transports/index.d.ts +70 -0
- package/dist/src/transports/index.js +87 -0
- package/dist/src/transports/metrics.d.ts +22 -0
- package/dist/src/transports/metrics.js +105 -0
- package/dist/src/transports/rest.d.ts +44 -0
- package/dist/src/transports/rest.js +131 -0
- package/dist/src/transports/util.d.ts +8 -0
- package/dist/src/transports/util.js +85 -0
- package/dist/src/transports/websocket.d.ts +80 -0
- package/dist/src/transports/websocket.js +166 -0
- package/dist/src/util/expiring-sorted-set.d.ts +21 -0
- package/dist/src/util/expiring-sorted-set.js +47 -0
- package/dist/src/util/index.d.ts +12 -0
- package/dist/src/util/index.js +35 -0
- package/dist/src/util/logger.d.ts +42 -0
- package/dist/src/util/logger.js +62 -0
- package/dist/src/util/request.d.ts +57 -0
- package/dist/src/util/request.js +2 -0
- package/dist/src/util/subscription-set/expiring-sorted-set.d.ts +22 -0
- package/dist/src/util/subscription-set/expiring-sorted-set.js +47 -0
- package/dist/src/util/subscription-set/subscription-set.d.ts +18 -0
- package/dist/src/util/subscription-set/subscription-set.js +19 -0
- package/dist/src/util/test-payload-loader.d.ts +25 -0
- package/dist/src/util/test-payload-loader.js +83 -0
- package/dist/src/validation/error.d.ts +50 -0
- package/dist/src/validation/error.js +79 -0
- package/dist/src/validation/index.d.ts +5 -0
- package/dist/src/validation/index.js +91 -0
- package/dist/src/validation/input-params.d.ts +15 -0
- package/dist/src/validation/input-params.js +30 -0
- package/dist/src/validation/override-functions.d.ts +3 -0
- package/dist/src/validation/override-functions.js +40 -0
- package/dist/src/validation/preset-tokens.json +23 -0
- package/dist/src/validation/validator.d.ts +47 -0
- package/dist/src/validation/validator.js +303 -0
- package/docker-compose.yaml +35 -0
- package/env.sh +54 -0
- package/env2.sh +55 -0
- package/package.json +5 -3
- package/publish.sh +0 -0
- package/src/adapter.ts +263 -0
- package/src/background-executor.ts +52 -0
- package/src/cache/factory.ts +26 -0
- package/src/cache/index.ts +258 -0
- package/src/cache/local.ts +73 -0
- package/src/cache/metrics.ts +112 -0
- package/src/cache/redis.ts +93 -0
- package/src/config/index.ts +517 -0
- package/src/config/provider-limits.ts +130 -0
- package/src/examples/bank-frick/README.MD +10 -0
- package/src/examples/bank-frick/accounts.ts +246 -0
- package/src/examples/bank-frick/config/index.ts +53 -0
- package/src/examples/bank-frick/index.ts +13 -0
- package/src/examples/bank-frick/types.d.ts +38 -0
- package/src/examples/bank-frick/util.ts +55 -0
- package/src/examples/coingecko/batch-warming.ts +78 -0
- package/src/examples/coingecko/index.ts +9 -0
- package/src/examples/coingecko/rest.ts +77 -0
- package/src/examples/ncfx/config/index.ts +12 -0
- package/src/examples/ncfx/index.ts +9 -0
- package/src/examples/ncfx/websocket.ts +99 -0
- package/src/index.ts +149 -0
- package/src/metrics/constants.ts +23 -0
- package/src/metrics/index.ts +115 -0
- package/src/metrics/util.ts +18 -0
- package/src/rate-limiting/background/fixed-frequency.ts +45 -0
- package/src/rate-limiting/index.ts +100 -0
- package/src/rate-limiting/metrics.ts +18 -0
- package/src/rate-limiting/request/simple-counting.ts +76 -0
- package/src/test.ts +5 -0
- package/src/transports/batch-warming.ts +122 -0
- package/src/transports/index.ts +152 -0
- package/src/transports/metrics.ts +95 -0
- package/src/transports/rest.ts +164 -0
- package/src/transports/util.ts +63 -0
- package/src/transports/websocket.ts +245 -0
- package/src/util/index.ts +22 -0
- package/src/util/logger.ts +69 -0
- package/src/util/request.ts +117 -0
- package/src/util/subscription-set/expiring-sorted-set.ts +54 -0
- package/src/util/subscription-set/subscription-set.ts +35 -0
- package/src/util/test-payload-loader.ts +87 -0
- package/src/validation/error.ts +116 -0
- package/src/validation/index.ts +110 -0
- package/src/validation/input-params.ts +45 -0
- package/src/validation/override-functions.ts +44 -0
- package/src/validation/preset-tokens.json +23 -0
- package/src/validation/validator.ts +384 -0
- package/test/adapter.test.ts +27 -0
- package/test/background-executor.test.ts +108 -0
- package/test/cache/cache-key.test.ts +114 -0
- package/test/cache/helper.ts +100 -0
- package/test/cache/local.test.ts +54 -0
- package/test/cache/redis.test.ts +89 -0
- package/test/correlation.test.ts +114 -0
- package/test/index.test.ts +37 -0
- package/test/metrics/feed-id.test.ts +38 -0
- package/test/metrics/helper.ts +14 -0
- package/test/metrics/labels.test.ts +36 -0
- package/test/metrics/metrics.test.ts +267 -0
- package/test/metrics/redis-metrics.test.ts +113 -0
- package/test/metrics/warmer-metrics.test.ts +192 -0
- package/test/metrics/ws-metrics.test.ts +225 -0
- package/test/rate-limit-config.test.ts +242 -0
- package/test/smoke.test.ts +166 -0
- package/test/transports/batch.test.ts +465 -0
- package/test/transports/rest.test.ts +242 -0
- package/test/transports/websocket.test.ts +183 -0
- package/test/tsconfig.json +5 -0
- package/test/util.ts +77 -0
- package/test/validation.test.ts +178 -0
- package/test-payload-fail.json +3 -0
- package/test-payload.js +22 -0
- package/test-payload.json +7 -0
- package/test.sh +20 -0
- package/test2.sh +2 -0
- package/tsconfig.json +25 -0
- package/typedoc.json +6 -0
- package/webpack.config.js +23 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.callBackgroundExecutes = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
const logger = (0, util_1.makeLogger)('BackgroundExecutor');
|
|
6
|
+
/**
|
|
7
|
+
* Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
|
|
8
|
+
* It gets the time in ms to wait as the return value from those functions, and sleeps until next execution.
|
|
9
|
+
*
|
|
10
|
+
* @param adapter - an initialized External Adapter
|
|
11
|
+
* @param server - the http server to attach an on close listener to
|
|
12
|
+
*/
|
|
13
|
+
async function callBackgroundExecutes(adapter, server) {
|
|
14
|
+
// Set up variable to check later on to see if we need to stop this background "thread"
|
|
15
|
+
// If no server is provided, the listener won't be set and serverClosed will always be false
|
|
16
|
+
let serverClosed = false;
|
|
17
|
+
server?.on('close', () => {
|
|
18
|
+
serverClosed = true;
|
|
19
|
+
});
|
|
20
|
+
for (const endpoint of adapter.endpoints) {
|
|
21
|
+
const backgroundExecute = endpoint.transport.backgroundExecute?.bind(endpoint.transport);
|
|
22
|
+
if (!backgroundExecute) {
|
|
23
|
+
logger.debug(`Endpoint "${endpoint.name}" has no background execute, skipping...`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const context = {
|
|
27
|
+
adapterEndpoint: endpoint,
|
|
28
|
+
adapterConfig: adapter.config,
|
|
29
|
+
};
|
|
30
|
+
const handler = async () => {
|
|
31
|
+
if (serverClosed) {
|
|
32
|
+
logger.info('Server closed, stopping recursive backgroundExecute handler chain');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
logger.debug(`Calling background execute for endpoint "${endpoint.name}"`);
|
|
36
|
+
const timeToWait = await backgroundExecute(context);
|
|
37
|
+
logger.debug(`Finished background execute for endpoint "${endpoint.name}", sleeping for ${timeToWait}ms`);
|
|
38
|
+
await (0, util_1.sleep)(timeToWait);
|
|
39
|
+
handler();
|
|
40
|
+
};
|
|
41
|
+
// Start recursive async calls
|
|
42
|
+
handler();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.callBackgroundExecutes = callBackgroundExecutes;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Cache, CacheEntry } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* Type for a value stored in a LocalCache entry.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam T - the type for the entry's value
|
|
6
|
+
*/
|
|
7
|
+
export interface LocalCacheEntry<T> {
|
|
8
|
+
expirationTimestamp: number;
|
|
9
|
+
value: T;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Local implementation of a Cache. It uses a simple js Object, storing entries with both
|
|
13
|
+
* a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
|
|
14
|
+
*
|
|
15
|
+
* @typeParam T - the type for the entries' values
|
|
16
|
+
*/
|
|
17
|
+
export declare class LocalCache<T = unknown> implements Cache<T> {
|
|
18
|
+
store: Record<string, LocalCacheEntry<T>>;
|
|
19
|
+
get(key: string): Promise<T | undefined>;
|
|
20
|
+
delete(key: string): Promise<void>;
|
|
21
|
+
set(key: string, value: T, ttl: number): Promise<void>;
|
|
22
|
+
setMany(entries: CacheEntry<T>[], ttl: number): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.LocalCache = void 0;
|
|
27
|
+
const util_1 = require("../util");
|
|
28
|
+
const cacheMetrics = __importStar(require("./metrics"));
|
|
29
|
+
const logger = (0, util_1.makeLogger)('LocalCache');
|
|
30
|
+
/**
|
|
31
|
+
* Local implementation of a Cache. It uses a simple js Object, storing entries with both
|
|
32
|
+
* a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
|
|
33
|
+
*
|
|
34
|
+
* @typeParam T - the type for the entries' values
|
|
35
|
+
*/
|
|
36
|
+
class LocalCache {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.store = {};
|
|
39
|
+
}
|
|
40
|
+
async get(key) {
|
|
41
|
+
logger.trace(`Getting key ${key}`);
|
|
42
|
+
const entry = this.store[key];
|
|
43
|
+
if (!entry) {
|
|
44
|
+
logger.debug(`No entry in local cache for key "${key}", returning undefined`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const expired = entry.expirationTimestamp <= Date.now();
|
|
48
|
+
if (expired) {
|
|
49
|
+
logger.debug('Entry in local cache expired, deleting and returning undefined');
|
|
50
|
+
this.delete(key);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
logger.debug('Found valid entry in local cache, returning value');
|
|
55
|
+
return entry.value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async delete(key) {
|
|
59
|
+
logger.trace(`Deleting key ${key}`);
|
|
60
|
+
delete this.store[key]; // Deletes are slower than ignoring or setting null, fyi
|
|
61
|
+
}
|
|
62
|
+
async set(key, value, ttl) {
|
|
63
|
+
logger.trace(`Setting key ${key} with ttl ${ttl}`);
|
|
64
|
+
this.store[key] = {
|
|
65
|
+
value,
|
|
66
|
+
expirationTimestamp: Date.now() + ttl,
|
|
67
|
+
};
|
|
68
|
+
// Only record metrics if feed Id is present, otherwise assuming value is not adapter response to record
|
|
69
|
+
const feedId = value.meta?.metrics?.feedId;
|
|
70
|
+
if (feedId) {
|
|
71
|
+
// Record cache set count, max age, and staleness (set to 0 for cache set)
|
|
72
|
+
const label = cacheMetrics.cacheMetricsLabel(key, feedId, cacheMetrics.CacheTypes.Local);
|
|
73
|
+
cacheMetrics.cacheSet(label, ttl);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async setMany(entries, ttl) {
|
|
77
|
+
logger.trace(`Setting a bunch of keys with ttl ${ttl}`);
|
|
78
|
+
for (const { key, value } of entries) {
|
|
79
|
+
this.set(key, value, ttl);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.LocalCache = LocalCache;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as client from 'prom-client';
|
|
2
|
+
interface CacheMetricsLabels {
|
|
3
|
+
participant_id: string;
|
|
4
|
+
feed_id: string;
|
|
5
|
+
cache_type: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const cacheGet: (label: CacheMetricsLabels, value: unknown, staleness: number) => void;
|
|
8
|
+
export declare const cacheSet: (label: CacheMetricsLabels, maxAge: number) => void;
|
|
9
|
+
export declare const cacheMetricsLabel: (cacheKey: string, feedId: string, cacheType: string) => {
|
|
10
|
+
participant_id: string;
|
|
11
|
+
feed_id: string;
|
|
12
|
+
cache_type: string;
|
|
13
|
+
};
|
|
14
|
+
export declare enum CacheTypes {
|
|
15
|
+
Redis = "redis",
|
|
16
|
+
Local = "local"
|
|
17
|
+
}
|
|
18
|
+
export declare enum CMD_SENT_STATUS {
|
|
19
|
+
TIMEOUT = "TIMEOUT",
|
|
20
|
+
FAIL = "FAIL",
|
|
21
|
+
SUCCESS = "SUCCESS"
|
|
22
|
+
}
|
|
23
|
+
export declare const redisConnectionsOpen: client.Counter<string>;
|
|
24
|
+
export declare const redisRetriesCount: client.Counter<string>;
|
|
25
|
+
export declare const redisCommandsSentCount: client.Counter<"status" | "function_name">;
|
|
26
|
+
export declare const cacheWarmerCount: client.Gauge<"isBatched">;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.cacheWarmerCount = exports.redisCommandsSentCount = exports.redisRetriesCount = exports.redisConnectionsOpen = exports.CMD_SENT_STATUS = exports.CacheTypes = exports.cacheMetricsLabel = exports.cacheSet = exports.cacheGet = void 0;
|
|
27
|
+
const client = __importStar(require("prom-client"));
|
|
28
|
+
const cacheGet = (label, value, staleness) => {
|
|
29
|
+
if (typeof value === 'number' || typeof value === 'string') {
|
|
30
|
+
const parsedValue = Number(value);
|
|
31
|
+
if (!Number.isNaN(parsedValue) && Number.isFinite(parsedValue)) {
|
|
32
|
+
cacheDataGetValues.labels(label).set(parsedValue);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
cacheDataGetCount.labels(label).inc();
|
|
36
|
+
cacheDataStalenessSeconds.labels(label).set(staleness);
|
|
37
|
+
};
|
|
38
|
+
exports.cacheGet = cacheGet;
|
|
39
|
+
const cacheSet = (label, maxAge) => {
|
|
40
|
+
cacheDataSetCount.labels(label).inc();
|
|
41
|
+
cacheDataMaxAge.labels(label).set(maxAge);
|
|
42
|
+
cacheDataStalenessSeconds.labels(label).set(0);
|
|
43
|
+
};
|
|
44
|
+
exports.cacheSet = cacheSet;
|
|
45
|
+
const cacheMetricsLabel = (cacheKey, feedId, cacheType) => ({
|
|
46
|
+
participant_id: cacheKey,
|
|
47
|
+
feed_id: feedId,
|
|
48
|
+
cache_type: cacheType,
|
|
49
|
+
});
|
|
50
|
+
exports.cacheMetricsLabel = cacheMetricsLabel;
|
|
51
|
+
var CacheTypes;
|
|
52
|
+
(function (CacheTypes) {
|
|
53
|
+
CacheTypes["Redis"] = "redis";
|
|
54
|
+
CacheTypes["Local"] = "local";
|
|
55
|
+
})(CacheTypes = exports.CacheTypes || (exports.CacheTypes = {}));
|
|
56
|
+
var CMD_SENT_STATUS;
|
|
57
|
+
(function (CMD_SENT_STATUS) {
|
|
58
|
+
CMD_SENT_STATUS["TIMEOUT"] = "TIMEOUT";
|
|
59
|
+
CMD_SENT_STATUS["FAIL"] = "FAIL";
|
|
60
|
+
CMD_SENT_STATUS["SUCCESS"] = "SUCCESS";
|
|
61
|
+
})(CMD_SENT_STATUS = exports.CMD_SENT_STATUS || (exports.CMD_SENT_STATUS = {}));
|
|
62
|
+
const baseLabels = [
|
|
63
|
+
'feed_id',
|
|
64
|
+
'participant_id',
|
|
65
|
+
'cache_type',
|
|
66
|
+
'is_from_ws',
|
|
67
|
+
'experimental',
|
|
68
|
+
];
|
|
69
|
+
// Skipping this metrics for v3
|
|
70
|
+
// const cache_execution_duration_seconds = new client.Histogram({
|
|
71
|
+
// name: 'cache_execution_duration_seconds',
|
|
72
|
+
// help: 'A histogram bucket of the distribution of cache execution durations',
|
|
73
|
+
// labelNames: [...baseLabels, 'cache_hit'] as const,
|
|
74
|
+
// buckets: [0.01, 0.1, 1, 10],
|
|
75
|
+
// })
|
|
76
|
+
const cacheDataGetCount = new client.Counter({
|
|
77
|
+
name: 'cache_data_get_count',
|
|
78
|
+
help: 'A counter that increments every time a value is fetched from the cache',
|
|
79
|
+
labelNames: baseLabels,
|
|
80
|
+
});
|
|
81
|
+
const cacheDataGetValues = new client.Gauge({
|
|
82
|
+
name: 'cache_data_get_values',
|
|
83
|
+
help: 'A gauge keeping track of values being fetched from cache',
|
|
84
|
+
labelNames: baseLabels,
|
|
85
|
+
});
|
|
86
|
+
const cacheDataMaxAge = new client.Gauge({
|
|
87
|
+
name: 'cache_data_max_age',
|
|
88
|
+
help: 'A gauge tracking the max age of stored values in the cache',
|
|
89
|
+
labelNames: baseLabels,
|
|
90
|
+
});
|
|
91
|
+
const cacheDataSetCount = new client.Counter({
|
|
92
|
+
name: 'cache_data_set_count',
|
|
93
|
+
help: 'A counter that increments every time a value is set to the cache',
|
|
94
|
+
labelNames: [...baseLabels, 'status_code'],
|
|
95
|
+
});
|
|
96
|
+
const cacheDataStalenessSeconds = new client.Gauge({
|
|
97
|
+
name: 'cache_data_staleness_seconds',
|
|
98
|
+
help: 'Observes the staleness of the data returned',
|
|
99
|
+
labelNames: baseLabels,
|
|
100
|
+
});
|
|
101
|
+
// Redis Metrics
|
|
102
|
+
exports.redisConnectionsOpen = new client.Counter({
|
|
103
|
+
name: 'redis_connections_open',
|
|
104
|
+
help: 'The number of redis connections that are open',
|
|
105
|
+
});
|
|
106
|
+
exports.redisRetriesCount = new client.Counter({
|
|
107
|
+
name: 'redis_retries_count',
|
|
108
|
+
help: 'The number of retries that have been made to establish a redis connection',
|
|
109
|
+
});
|
|
110
|
+
exports.redisCommandsSentCount = new client.Counter({
|
|
111
|
+
name: 'redis_commands_sent_count',
|
|
112
|
+
help: 'The number of redis commands sent',
|
|
113
|
+
labelNames: ['status', 'function_name'],
|
|
114
|
+
});
|
|
115
|
+
// Cache Warmer Metrics
|
|
116
|
+
exports.cacheWarmerCount = new client.Gauge({
|
|
117
|
+
name: 'cache_warmer_get_count',
|
|
118
|
+
help: 'The number of cache warmers running',
|
|
119
|
+
labelNames: ['isBatched'],
|
|
120
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
import { Cache, CacheEntry } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Redis implementation of a Cache. It uses a simple js Object, storing entries with both
|
|
5
|
+
* a value and an expiration timestamp. Expired entries are deleted on reads (i.e. no background gc/upkeep).
|
|
6
|
+
*
|
|
7
|
+
* @typeParam T - the type for the entries' values
|
|
8
|
+
*/
|
|
9
|
+
export declare class RedisCache<T = unknown> implements Cache<T> {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: Redis);
|
|
12
|
+
get(key: string): Promise<T | undefined>;
|
|
13
|
+
delete(key: string): Promise<void>;
|
|
14
|
+
set(key: string, value: T, ttl: number): Promise<void>;
|
|
15
|
+
setMany(entries: CacheEntry<T>[], ttl: number): Promise<void>;
|
|
16
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const DEFAULT_MINUTE_RATE_LIMIT = 60;
|
|
2
|
+
export declare const BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
|
|
3
|
+
export declare const DEFAULT_WS_CONNECTIONS = 2;
|
|
4
|
+
export declare const DEFAULT_WS_SUBSCRIPTIONS = 10;
|
|
5
|
+
declare type RateLimitTimeFrame = 'rateLimit1s' | 'rateLimit1m' | 'rateLimit1h';
|
|
6
|
+
declare type HTTPTier = {
|
|
7
|
+
rateLimit1s?: number;
|
|
8
|
+
rateLimit1m?: number;
|
|
9
|
+
rateLimit1h?: number;
|
|
10
|
+
note?: string;
|
|
11
|
+
};
|
|
12
|
+
declare type WSTier = {
|
|
13
|
+
connections: number;
|
|
14
|
+
subscriptions: number;
|
|
15
|
+
};
|
|
16
|
+
export interface Limits {
|
|
17
|
+
http: {
|
|
18
|
+
[tierName: string]: HTTPTier;
|
|
19
|
+
};
|
|
20
|
+
ws: {
|
|
21
|
+
[tierName: string]: WSTier;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
interface ProviderRateLimit {
|
|
25
|
+
second: number;
|
|
26
|
+
minute: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const getHTTPLimit: (provider: string, limits: Limits, tier: string, timeframe: RateLimitTimeFrame) => number;
|
|
29
|
+
export declare const getRateLimit: (provider: string, limits: Limits, tier: string) => ProviderRateLimit;
|
|
30
|
+
export declare const getWSLimits: (provider: string, limits: Limits, tier: string) => WSTier;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWSLimits = exports.getRateLimit = exports.getHTTPLimit = exports.DEFAULT_WS_SUBSCRIPTIONS = exports.DEFAULT_WS_CONNECTIONS = exports.BURST_UNDEFINED_QUOTA_MULTIPLE = exports.DEFAULT_MINUTE_RATE_LIMIT = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
exports.DEFAULT_MINUTE_RATE_LIMIT = 60;
|
|
6
|
+
exports.BURST_UNDEFINED_QUOTA_MULTIPLE = 2;
|
|
7
|
+
exports.DEFAULT_WS_CONNECTIONS = 2;
|
|
8
|
+
exports.DEFAULT_WS_SUBSCRIPTIONS = 10;
|
|
9
|
+
const logger = (0, util_1.makeLogger)('ProviderLimits');
|
|
10
|
+
const getHTTPLimit = (provider, limits, tier, timeframe) => {
|
|
11
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
12
|
+
return providerLimit?.[timeframe] || 0;
|
|
13
|
+
};
|
|
14
|
+
exports.getHTTPLimit = getHTTPLimit;
|
|
15
|
+
const getRateLimit = (provider, limits, tier) => {
|
|
16
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'http');
|
|
17
|
+
return calculateRateLimit(providerLimit);
|
|
18
|
+
};
|
|
19
|
+
exports.getRateLimit = getRateLimit;
|
|
20
|
+
const getWSLimits = (provider, limits, tier) => {
|
|
21
|
+
const providerLimit = getProviderLimits(provider, limits, tier, 'ws');
|
|
22
|
+
return calculateWSLimits(providerLimit);
|
|
23
|
+
};
|
|
24
|
+
exports.getWSLimits = getWSLimits;
|
|
25
|
+
const getProviderLimits = (provider, limits, tier, protocol) => {
|
|
26
|
+
const providerConfig = parseLimits(limits);
|
|
27
|
+
if (!providerConfig) {
|
|
28
|
+
throw new Error(`Rate Limit: Provider: "${provider}" doesn't match any provider spec in limits.json`);
|
|
29
|
+
}
|
|
30
|
+
const protocolConfig = providerConfig[protocol];
|
|
31
|
+
if (!protocolConfig) {
|
|
32
|
+
throw new Error(`Rate Limit: "${provider}" doesn't have any configuration for ${protocol} in limits.json`);
|
|
33
|
+
}
|
|
34
|
+
let limitsConfig = protocolConfig[tier.toLowerCase()];
|
|
35
|
+
if (!limitsConfig) {
|
|
36
|
+
logger.debug(`Rate Limit: "${provider} does not have tier ${tier} defined. Falling back to lowest tier"`);
|
|
37
|
+
limitsConfig = Object.values(protocolConfig)?.[0];
|
|
38
|
+
}
|
|
39
|
+
if (!limitsConfig) {
|
|
40
|
+
throw new Error(`Rate Limit: Provider: "${provider}" has no tiers defined for ${protocol} in limits.json`);
|
|
41
|
+
}
|
|
42
|
+
return limitsConfig;
|
|
43
|
+
};
|
|
44
|
+
const parseLimits = (limits) => {
|
|
45
|
+
// const _mapObject = (fn: any) => (o: any) => Object.fromEntries(Object.entries(o).map(fn))
|
|
46
|
+
const _mapObject = (fn) => (o) => Object.fromEntries([]);
|
|
47
|
+
const _formatProtocol = _mapObject((entry) => {
|
|
48
|
+
const [tierName, rest] = entry;
|
|
49
|
+
return [tierName.toLowerCase(), { ...rest }];
|
|
50
|
+
});
|
|
51
|
+
const _formatProvider = (ls) => {
|
|
52
|
+
const http = _formatProtocol(ls.http);
|
|
53
|
+
const ws = _formatProtocol(ls?.ws);
|
|
54
|
+
return { http, ws };
|
|
55
|
+
};
|
|
56
|
+
return _formatProvider(limits);
|
|
57
|
+
};
|
|
58
|
+
const calculateWSLimits = (providerLimit) => {
|
|
59
|
+
return {
|
|
60
|
+
connections: providerLimit.connections,
|
|
61
|
+
subscriptions: providerLimit.subscriptions,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const calculateRateLimit = (providerLimit) => {
|
|
65
|
+
let quota = providerLimit.rateLimit1m;
|
|
66
|
+
if (!quota && providerLimit?.rateLimit1h) {
|
|
67
|
+
quota = providerLimit?.rateLimit1h / 60;
|
|
68
|
+
}
|
|
69
|
+
else if (!quota && providerLimit?.rateLimit1s) {
|
|
70
|
+
quota = providerLimit?.rateLimit1s * 60;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
second: providerLimit?.rateLimit1s || (quota / 60) * exports.BURST_UNDEFINED_QUOTA_MULTIPLE,
|
|
74
|
+
minute: quota,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const customSettings: {
|
|
2
|
+
readonly USERNAME: {
|
|
3
|
+
readonly description: "Username for the NCFX API";
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly PASSWORD: {
|
|
8
|
+
readonly description: "Password for the NCFX API";
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly required: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customSettings = void 0;
|
|
4
|
+
exports.customSettings = {
|
|
5
|
+
USERNAME: {
|
|
6
|
+
description: 'Username for the NCFX API',
|
|
7
|
+
type: 'string',
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
PASSWORD: {
|
|
11
|
+
description: 'Password for the NCFX API',
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum HttpRequestType {
|
|
2
|
+
CACHE_HIT = "cacheHit",
|
|
3
|
+
DATA_PROVIDER_HIT = "dataProviderHit",
|
|
4
|
+
ADAPTER_ERROR = "adapterError",
|
|
5
|
+
INPUT_ERROR = "inputError",
|
|
6
|
+
RATE_LIMIT_ERROR = "rateLimitError",
|
|
7
|
+
DP_ERROR = "dataProviderError",
|
|
8
|
+
TIMEOUT_ERROR = "timeoutError",
|
|
9
|
+
CONNECTION_ERROR = "connectionError",
|
|
10
|
+
CUSTOM_ERROR = "customError"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Maxiumum number of characters that a feedId can contain.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MAX_FEED_ID_LENGTH = 300;
|
|
16
|
+
export declare const requestDurationBuckets: number[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestDurationBuckets = exports.MAX_FEED_ID_LENGTH = exports.HttpRequestType = void 0;
|
|
4
|
+
var HttpRequestType;
|
|
5
|
+
(function (HttpRequestType) {
|
|
6
|
+
HttpRequestType["CACHE_HIT"] = "cacheHit";
|
|
7
|
+
HttpRequestType["DATA_PROVIDER_HIT"] = "dataProviderHit";
|
|
8
|
+
HttpRequestType["ADAPTER_ERROR"] = "adapterError";
|
|
9
|
+
HttpRequestType["INPUT_ERROR"] = "inputError";
|
|
10
|
+
HttpRequestType["RATE_LIMIT_ERROR"] = "rateLimitError";
|
|
11
|
+
// BURST_LIMIT_ERROR = 'burstLimitError',
|
|
12
|
+
// BACKOFF_ERROR = 'backoffError',
|
|
13
|
+
HttpRequestType["DP_ERROR"] = "dataProviderError";
|
|
14
|
+
HttpRequestType["TIMEOUT_ERROR"] = "timeoutError";
|
|
15
|
+
HttpRequestType["CONNECTION_ERROR"] = "connectionError";
|
|
16
|
+
// RES_EMPTY_ERROR = 'responseEmptyError',
|
|
17
|
+
// RES_INVALID_ERROR = 'responseInvalidError',
|
|
18
|
+
HttpRequestType["CUSTOM_ERROR"] = "customError";
|
|
19
|
+
})(HttpRequestType = exports.HttpRequestType || (exports.HttpRequestType = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Maxiumum number of characters that a feedId can contain.
|
|
22
|
+
*/
|
|
23
|
+
exports.MAX_FEED_ID_LENGTH = 300;
|
|
24
|
+
// We should tune these as we collect data, this is the default bucket distribution that prom comes with
|
|
25
|
+
exports.requestDurationBuckets = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as client from 'prom-client';
|
|
2
|
+
import { AdapterRequest } from '../util';
|
|
3
|
+
import { AdapterConfig } from '../config';
|
|
4
|
+
import { FastifyReply, HookHandlerDoneFunction } from 'fastify';
|
|
5
|
+
export declare function setupMetricsServer(name: string, config: AdapterConfig): void;
|
|
6
|
+
export declare const setupMetrics: (name: string, config: AdapterConfig) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Builds metrics middleware that records end to end EA response times
|
|
9
|
+
* and count of requests
|
|
10
|
+
*
|
|
11
|
+
* @returns the cache middleware function
|
|
12
|
+
*/
|
|
13
|
+
export declare const buildMetricsMiddleware: (req: AdapterRequest, res: FastifyReply, done: HookHandlerDoneFunction) => void;
|
|
14
|
+
export declare const httpRequestsTotal: client.Counter<"type" | "method" | "feed_id" | "status_code" | "provider_status_code" | "retry" | "is_cache_warming">;
|
|
15
|
+
export declare const httpRequestDurationSeconds: client.Histogram<string>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainlink/external-adapter-framework",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"axios": "^0.27.2",
|
|
8
|
+
"fastify": "^3.29.0",
|
|
9
|
+
"ioredis": "^5.0.4",
|
|
10
|
+
"pino": "^7.9.2",
|
|
11
|
+
"prom-client": "13.2.0",
|
|
12
|
+
"ts-node": "^10.9.1",
|
|
13
|
+
"typescript": "^4.6.3",
|
|
14
|
+
"ws": "^8.5.0"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "ts-node src/test.ts",
|
|
18
|
+
"generate-docs": "typedoc src/**/*.ts",
|
|
19
|
+
"test": "LOG_LEVEL=error EA_PORT=0 c8 ava",
|
|
20
|
+
"test-debug": "LOG_LEVEL=trace DEBUG=true EA_PORT=0 c8 ava --verbose",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"lint": "eslint ./src"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@sinonjs/fake-timers": "^9.1.2",
|
|
26
|
+
"@types/node": "^18.6.5",
|
|
27
|
+
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
28
|
+
"@types/ws": "^8.5.3",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
30
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
31
|
+
"ava": "^4.2.0",
|
|
32
|
+
"c8": "^7.11.2",
|
|
33
|
+
"eslint": "^8.14.0",
|
|
34
|
+
"eslint-config-prettier": "^8.5.0",
|
|
35
|
+
"eslint-plugin-tsdoc": "^0.2.16",
|
|
36
|
+
"mock-socket": "^9.1.3",
|
|
37
|
+
"nock": "^13.2.4",
|
|
38
|
+
"pino-pretty": "^7.6.0",
|
|
39
|
+
"prettier": "^2.6.1",
|
|
40
|
+
"ts-loader": "^9.3.1",
|
|
41
|
+
"typedoc": "^0.22.15",
|
|
42
|
+
"webpack": "^5.74.0",
|
|
43
|
+
"webpack-cli": "^4.10.0"
|
|
44
|
+
},
|
|
45
|
+
"prettier": {
|
|
46
|
+
"semi": false,
|
|
47
|
+
"singleQuote": true,
|
|
48
|
+
"printWidth": 100,
|
|
49
|
+
"endOfLine": "auto",
|
|
50
|
+
"trailingComma": "all",
|
|
51
|
+
"arrowParens": "always"
|
|
52
|
+
},
|
|
53
|
+
"optionalDependencies": {
|
|
54
|
+
"bufferutil": "^4.0.6",
|
|
55
|
+
"utf-8-validate": "^5.0.9"
|
|
56
|
+
},
|
|
57
|
+
"ava": {
|
|
58
|
+
"files": [
|
|
59
|
+
"test/**/*.test.ts"
|
|
60
|
+
],
|
|
61
|
+
"extensions": [
|
|
62
|
+
"ts"
|
|
63
|
+
],
|
|
64
|
+
"require": [
|
|
65
|
+
"ts-node/register"
|
|
66
|
+
],
|
|
67
|
+
"workerThreads": false,
|
|
68
|
+
"environmentVariables": {
|
|
69
|
+
"METRICS_ENABLED": "false"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|