@chainlink/external-adapter-framework 0.0.41 → 0.0.43

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/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@chainlink/external-adapter-framework",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "ajv": "^8.11.0",
8
7
  "axios": "^0.27.2",
9
8
  "fastify": "^4.5.3",
10
9
  "ioredis": "^5.0.4",
@@ -28,8 +27,8 @@
28
27
  },
29
28
  "devDependencies": {
30
29
  "@sinonjs/fake-timers": "^9.1.2",
31
- "@types/jest": "^29.0.3",
32
- "@types/node": "^18.7.18",
30
+ "@types/jest": "^28.1.7",
31
+ "@types/node": "^18.6.5",
33
32
  "@types/sinonjs__fake-timers": "^8.1.2",
34
33
  "@types/supertest": "^2.0.12",
35
34
  "@types/ws": "^8.5.3",
@@ -12,6 +12,9 @@ class FixedFrequencyRateLimiter {
12
12
  initialize(endpoints, limits) {
13
13
  // Translate the hourly limit into reqs per minute
14
14
  let sharedMsBetweenRequests = 1000 / (0, __1.consolidateTierLimits)(limits);
15
+ console.log(limits);
16
+ console.log(sharedMsBetweenRequests);
17
+ console.log((0, __1.consolidateTierLimits)(limits));
15
18
  // If there is no limit set, we use some reasonable number
16
19
  if (!limits?.rateLimit1h && !limits?.rateLimit1m && !limits?.rateLimit1s) {
17
20
  // 5s period for all seems good
@@ -56,20 +56,11 @@ class BatchWarmingTransport {
56
56
  this.subscriptionSet = dependencies.subscriptionSetFactory.buildSet();
57
57
  }
58
58
  async hasBeenSetUp(req) {
59
- logger.debug(`Checking if entry is in batch warming set: [${req.requestContext.cacheKey}]`);
60
- logger.debug(`!!(await this.subscriptionSet.get(req.requestContext.cacheKey)) ${!!(await this.subscriptionSet.get(req.requestContext.cacheKey))}`);
61
59
  return !!(await this.subscriptionSet.get(req.requestContext.cacheKey));
62
60
  }
63
61
  async setup(req, config) {
64
62
  logger.debug(`Adding entry to batch warming set: [${req.requestContext.cacheKey}] = ${req.requestContext.data}`);
65
- logger.debug('about to add to subscription set');
66
- const res = await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data, config.WARMUP_SUBSCRIPTION_TTL);
67
- logger.debug('done adding to subscription set');
68
- logger.debug(`Adding subscription set res ${res}`);
69
- logger.debug(`Get request ${await this.subscriptionSet.get(req.requestContext.cacheKey)}`);
70
- logger.debug(`!!(await this.subscriptionSet.get(req.requestContext.cacheKey)t; ${!!(await this.subscriptionSet.get(req.requestContext.cacheKey))}`);
71
- logger.debug(`!await this.subscriptionSet.get(req.requestContext.cacheKey)t; ${!(await this.subscriptionSet.get(req.requestContext.cacheKey))}`);
72
- logger.debug(`await this.subscriptionSet.get(req.requestContext.cacheKey)t; ${this.subscriptionSet.get(req.requestContext.cacheKey)}`);
63
+ await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data, config.WARMUP_SUBSCRIPTION_TTL);
73
64
  }
74
65
  async backgroundExecute(context) {
75
66
  logger.debug('Starting background execute');
@@ -77,12 +68,10 @@ class BatchWarmingTransport {
77
68
  if (!entries.length) {
78
69
  logger.debug('No entries in batch warming set, skipping');
79
70
  if (this.WARMER_ACTIVE) {
80
- logger.debug(this.WARMER_ACTIVE);
81
71
  // Decrement count when warmer changed from having entries to having none
82
72
  cacheMetrics.cacheWarmerCount.labels({ isBatched: 'true' }).dec();
83
73
  this.WARMER_ACTIVE = false;
84
74
  }
85
- logger.debug(this.WARMER_ACTIVE);
86
75
  return this.rateLimiter.msUntilNextExecution(context.adapterEndpoint.name);
87
76
  }
88
77
  else if (this.WARMER_ACTIVE === false) {
@@ -90,7 +79,6 @@ class BatchWarmingTransport {
90
79
  cacheMetrics.cacheWarmerCount.labels({ isBatched: 'true' }).inc();
91
80
  this.WARMER_ACTIVE = true;
92
81
  }
93
- logger.debug('Preparing request');
94
82
  const request = this.config.prepareRequest(entries, context);
95
83
  logger.trace('Sending request to data provider...');
96
84
  const providerResponse = await (0, util_2.axiosRequest)(request, context.adapterConfig);
@@ -23,14 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.wsMessageTotal = exports.wsSubscriptionTotal = exports.wsSubscriptionActive = exports.wsConnectionErrors = exports.wsConnectionActive = exports.recordWsMessageMetrics = exports.messageSubsLabels = exports.connectionErrorLabels = exports.dataProviderRequestDurationSeconds = exports.dataProviderRequests = exports.dataProviderMetricsLabel = exports.clearRegistry = void 0;
26
+ exports.wsMessageTotal = exports.wsSubscriptionTotal = exports.wsSubscriptionActive = exports.wsConnectionErrors = exports.wsConnectionActive = exports.recordWsMessageMetrics = exports.messageSubsLabels = exports.connectionErrorLabels = exports.dataProviderRequestDurationSeconds = exports.dataProviderRequests = exports.dataProviderMetricsLabel = void 0;
27
27
  const client = __importStar(require("prom-client"));
28
28
  const cache_1 = require("../cache");
29
29
  const constants_1 = require("../metrics/constants");
30
- const clearRegistry = () => {
31
- client.register.clear();
32
- };
33
- exports.clearRegistry = clearRegistry;
34
30
  // Data Provider Metrics
35
31
  const dataProviderMetricsLabel = (providerStatusCode, method = 'get') => ({
36
32
  provider_status_code: providerStatusCode,
@@ -22,7 +22,7 @@ class ExpiringSortedSet {
22
22
  if (!entry) {
23
23
  return;
24
24
  }
25
- else if (entry.expirationTimestamp > Date.now()) {
25
+ else if (entry.expirationTimestamp < Date.now()) {
26
26
  return entry.value;
27
27
  }
28
28
  else {