@chainlink/external-adapter-framework 0.3.9 → 0.4.0
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/README.md +102 -0
- package/package.json +42 -50
- package/adapter/basic.d.ts +0 -86
- package/adapter/basic.js +0 -325
- package/adapter/basic.js.map +0 -1
- package/adapter/endpoint.d.ts +0 -17
- package/adapter/endpoint.js +0 -19
- package/adapter/endpoint.js.map +0 -1
- package/adapter/index.d.ts +0 -4
- package/adapter/index.js +0 -21
- package/adapter/index.js.map +0 -1
- package/adapter/price.d.ts +0 -75
- package/adapter/price.js +0 -88
- package/adapter/price.js.map +0 -1
- package/adapter/types.d.ts +0 -118
- package/adapter/types.js +0 -3
- package/adapter/types.js.map +0 -1
- package/background-executor.d.ts +0 -9
- package/background-executor.js +0 -97
- package/background-executor.js.map +0 -1
- package/cache/factory.d.ts +0 -6
- package/cache/factory.js +0 -24
- package/cache/factory.js.map +0 -1
- package/cache/index.d.ts +0 -87
- package/cache/index.js +0 -133
- package/cache/index.js.map +0 -1
- package/cache/local.d.ts +0 -23
- package/cache/local.js +0 -84
- package/cache/local.js.map +0 -1
- package/cache/metrics.d.ts +0 -27
- package/cache/metrics.js +0 -121
- package/cache/metrics.js.map +0 -1
- package/cache/redis.d.ts +0 -16
- package/cache/redis.js +0 -101
- package/cache/redis.js.map +0 -1
- package/config/index.d.ts +0 -298
- package/config/index.js +0 -359
- package/config/index.js.map +0 -1
- package/config/provider-limits.d.ts +0 -27
- package/config/provider-limits.js +0 -75
- package/config/provider-limits.js.map +0 -1
- package/examples/bank-frick/accounts.d.ts +0 -52
- package/examples/bank-frick/accounts.js +0 -190
- package/examples/bank-frick/accounts.js.map +0 -1
- package/examples/bank-frick/config/index.d.ts +0 -17
- package/examples/bank-frick/config/index.js +0 -55
- package/examples/bank-frick/config/index.js.map +0 -1
- package/examples/bank-frick/index.d.ts +0 -16
- package/examples/bank-frick/index.js +0 -16
- package/examples/bank-frick/index.js.map +0 -1
- package/examples/bank-frick/util.d.ts +0 -4
- package/examples/bank-frick/util.js +0 -40
- package/examples/bank-frick/util.js.map +0 -1
- package/examples/coingecko/src/config/index.d.ts +0 -2
- package/examples/coingecko/src/config/index.js +0 -6
- package/examples/coingecko/src/config/index.js.map +0 -1
- package/examples/coingecko/src/config/overrides.json +0 -10825
- package/examples/coingecko/src/crypto-utils.d.ts +0 -48
- package/examples/coingecko/src/crypto-utils.js +0 -60
- package/examples/coingecko/src/crypto-utils.js.map +0 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
- package/examples/coingecko/src/endpoint/coins.js +0 -37
- package/examples/coingecko/src/endpoint/coins.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
- package/examples/coingecko/src/endpoint/crypto-volume.js +0 -30
- package/examples/coingecko/src/endpoint/crypto-volume.js.map +0 -1
- package/examples/coingecko/src/endpoint/crypto.d.ts +0 -2
- package/examples/coingecko/src/endpoint/crypto.js +0 -28
- package/examples/coingecko/src/endpoint/crypto.js.map +0 -1
- package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
- package/examples/coingecko/src/endpoint/dominance.js +0 -28
- package/examples/coingecko/src/endpoint/dominance.js.map +0 -1
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
- package/examples/coingecko/src/endpoint/global-marketcap.js +0 -28
- package/examples/coingecko/src/endpoint/global-marketcap.js.map +0 -1
- package/examples/coingecko/src/endpoint/index.d.ts +0 -6
- package/examples/coingecko/src/endpoint/index.js +0 -16
- package/examples/coingecko/src/endpoint/index.js.map +0 -1
- package/examples/coingecko/src/global-utils.d.ts +0 -27
- package/examples/coingecko/src/global-utils.js +0 -47
- package/examples/coingecko/src/global-utils.js.map +0 -1
- package/examples/coingecko/src/index.d.ts +0 -4
- package/examples/coingecko/src/index.js +0 -19
- package/examples/coingecko/src/index.js.map +0 -1
- package/examples/coingecko-old/batch-warming.d.ts +0 -7
- package/examples/coingecko-old/batch-warming.js +0 -54
- package/examples/coingecko-old/batch-warming.js.map +0 -1
- package/examples/coingecko-old/index.d.ts +0 -2
- package/examples/coingecko-old/index.js +0 -12
- package/examples/coingecko-old/index.js.map +0 -1
- package/examples/coingecko-old/rest.d.ts +0 -12
- package/examples/coingecko-old/rest.js +0 -55
- package/examples/coingecko-old/rest.js.map +0 -1
- package/examples/cryptocompare/src/config/index.d.ts +0 -2
- package/examples/cryptocompare/src/config/index.js +0 -6
- package/examples/cryptocompare/src/config/index.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/crypto.d.ts +0 -28
- package/examples/cryptocompare/src/endpoints/crypto.js +0 -54
- package/examples/cryptocompare/src/endpoints/crypto.js.map +0 -1
- package/examples/cryptocompare/src/endpoints/index.d.ts +0 -1
- package/examples/cryptocompare/src/endpoints/index.js +0 -6
- package/examples/cryptocompare/src/endpoints/index.js.map +0 -1
- package/examples/cryptocompare/src/index.d.ts +0 -4
- package/examples/cryptocompare/src/index.js +0 -14
- package/examples/cryptocompare/src/index.js.map +0 -1
- package/examples/genesis/config/index.d.ts +0 -7
- package/examples/genesis/config/index.js +0 -11
- package/examples/genesis/config/index.js.map +0 -1
- package/examples/genesis/index.d.ts +0 -2
- package/examples/genesis/index.js +0 -13
- package/examples/genesis/index.js.map +0 -1
- package/examples/genesis/sseStream.d.ts +0 -16
- package/examples/genesis/sseStream.js +0 -149
- package/examples/genesis/sseStream.js.map +0 -1
- package/index.d.ts +0 -17
- package/index.js +0 -174
- package/index.js.map +0 -1
- package/metrics/constants.d.ts +0 -16
- package/metrics/constants.js +0 -26
- package/metrics/constants.js.map +0 -1
- package/metrics/index.d.ts +0 -19
- package/metrics/index.js +0 -139
- package/metrics/index.js.map +0 -1
- package/metrics/util.d.ts +0 -7
- package/metrics/util.js +0 -10
- package/metrics/util.js.map +0 -1
- package/rate-limiting/background/fixed-frequency.d.ts +0 -11
- package/rate-limiting/background/fixed-frequency.js +0 -36
- package/rate-limiting/background/fixed-frequency.js.map +0 -1
- package/rate-limiting/index.d.ts +0 -56
- package/rate-limiting/index.js +0 -86
- package/rate-limiting/index.js.map +0 -1
- package/rate-limiting/metrics.d.ts +0 -3
- package/rate-limiting/metrics.js +0 -45
- package/rate-limiting/metrics.js.map +0 -1
- package/rate-limiting/request/simple-counting.d.ts +0 -21
- package/rate-limiting/request/simple-counting.js +0 -63
- package/rate-limiting/request/simple-counting.js.map +0 -1
- package/transports/batch-warming.d.ts +0 -35
- package/transports/batch-warming.js +0 -138
- package/transports/batch-warming.js.map +0 -1
- package/transports/index.d.ts +0 -87
- package/transports/index.js +0 -56
- package/transports/index.js.map +0 -1
- package/transports/metrics.d.ts +0 -25
- package/transports/metrics.js +0 -122
- package/transports/metrics.js.map +0 -1
- package/transports/rest.d.ts +0 -51
- package/transports/rest.js +0 -133
- package/transports/rest.js.map +0 -1
- package/transports/routing.d.ts +0 -23
- package/transports/routing.js +0 -52
- package/transports/routing.js.map +0 -1
- package/transports/sse.d.ts +0 -40
- package/transports/sse.js +0 -92
- package/transports/sse.js.map +0 -1
- package/transports/util.d.ts +0 -9
- package/transports/util.js +0 -87
- package/transports/util.js.map +0 -1
- package/transports/websocket.d.ts +0 -81
- package/transports/websocket.js +0 -165
- package/transports/websocket.js.map +0 -1
- package/util/censor/censor-list.d.ts +0 -9
- package/util/censor/censor-list.js +0 -13
- package/util/censor/censor-list.js.map +0 -1
- package/util/index.d.ts +0 -13
- package/util/index.js +0 -38
- package/util/index.js.map +0 -1
- package/util/logger.d.ts +0 -49
- package/util/logger.js +0 -123
- package/util/logger.js.map +0 -1
- package/util/request.d.ts +0 -102
- package/util/request.js +0 -3
- package/util/request.js.map +0 -1
- package/util/subscription-set/expiring-sorted-set.d.ts +0 -21
- package/util/subscription-set/expiring-sorted-set.js +0 -36
- package/util/subscription-set/expiring-sorted-set.js.map +0 -1
- package/util/subscription-set/redis-sorted-set.d.ts +0 -9
- package/util/subscription-set/redis-sorted-set.js +0 -29
- package/util/subscription-set/redis-sorted-set.js.map +0 -1
- package/util/subscription-set/subscription-set.d.ts +0 -19
- package/util/subscription-set/subscription-set.js +0 -28
- package/util/subscription-set/subscription-set.js.map +0 -1
- package/util/test-payload-loader.d.ts +0 -26
- package/util/test-payload-loader.js +0 -85
- package/util/test-payload-loader.js.map +0 -1
- package/validation/error.d.ts +0 -48
- package/validation/error.js +0 -78
- package/validation/error.js.map +0 -1
- package/validation/index.d.ts +0 -5
- package/validation/index.js +0 -91
- package/validation/index.js.map +0 -1
- package/validation/input-params.d.ts +0 -14
- package/validation/input-params.js +0 -3
- package/validation/input-params.js.map +0 -1
- package/validation/input-validator.d.ts +0 -16
- package/validation/input-validator.js +0 -123
- package/validation/input-validator.js.map +0 -1
package/transports/routing.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AdapterRequest, AdapterResponse } from '../util/request';
|
|
2
|
-
import { MetaTransport, Transport } from './';
|
|
3
|
-
import { AdapterConfig, SettingsMap } from '../config';
|
|
4
|
-
import { AdapterDependencies } from '../adapter';
|
|
5
|
-
/**
|
|
6
|
-
* Transport implementation that takes 2 or more transports and a function that determines with transport to use.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam AdapterParams - interface for the adapter request body
|
|
9
|
-
* @typeParam AdapterResult - interface for the adapter's response body
|
|
10
|
-
* @typeParam CustomSettings - interface for the adapter's custom settings.
|
|
11
|
-
*/
|
|
12
|
-
export declare class RoutingTransport<AdapterParams, AdapterResult, CustomSettings extends SettingsMap> implements MetaTransport<AdapterParams, AdapterResult, CustomSettings> {
|
|
13
|
-
transports: {
|
|
14
|
-
[key: string]: Transport<unknown, unknown, CustomSettings>;
|
|
15
|
-
};
|
|
16
|
-
private route;
|
|
17
|
-
constructor(transports: {
|
|
18
|
-
[key: string]: Transport<unknown, unknown, CustomSettings>;
|
|
19
|
-
}, route: (req: AdapterRequest<AdapterParams>, adapterConfig?: AdapterConfig<CustomSettings>) => string);
|
|
20
|
-
initialize(dependencies: AdapterDependencies, adapterConfig: AdapterConfig<CustomSettings>, endpointName: string): Promise<void>;
|
|
21
|
-
private resolveTransport;
|
|
22
|
-
foregroundExecute(req: AdapterRequest<AdapterParams>, adapterConfig: AdapterConfig<CustomSettings>): Promise<AdapterResponse<any> | void>;
|
|
23
|
-
}
|
package/transports/routing.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoutingTransport = void 0;
|
|
4
|
-
const util_1 = require("../util");
|
|
5
|
-
const error_1 = require("../validation/error");
|
|
6
|
-
const logger = (0, util_1.makeLogger)('RoutingTransport');
|
|
7
|
-
/**
|
|
8
|
-
* Transport implementation that takes 2 or more transports and a function that determines with transport to use.
|
|
9
|
-
*
|
|
10
|
-
* @typeParam AdapterParams - interface for the adapter request body
|
|
11
|
-
* @typeParam AdapterResult - interface for the adapter's response body
|
|
12
|
-
* @typeParam CustomSettings - interface for the adapter's custom settings.
|
|
13
|
-
*/
|
|
14
|
-
class RoutingTransport {
|
|
15
|
-
constructor(
|
|
16
|
-
// This is public for tests, which sometimes need the underlying transport for things like ticking the clock
|
|
17
|
-
transports,
|
|
18
|
-
// Route should return to a string key that corresponds to a transport in the transports object
|
|
19
|
-
route) {
|
|
20
|
-
this.transports = transports;
|
|
21
|
-
this.route = route;
|
|
22
|
-
}
|
|
23
|
-
async initialize(dependencies, adapterConfig, endpointName) {
|
|
24
|
-
logger.debug(`Initializing ${Object.keys(this.transports).length} transports`);
|
|
25
|
-
Object.entries(this.transports).forEach(([k, v]) => {
|
|
26
|
-
logger.debug(`Initializing transport ${k} (${v.constructor.name})`);
|
|
27
|
-
v.initialize(dependencies, adapterConfig, endpointName);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
resolveTransport(req, adapterConfig) {
|
|
31
|
-
logger.debug(`routing request using`, req.params);
|
|
32
|
-
const key = this.route(req, adapterConfig || undefined);
|
|
33
|
-
if (!this.transports[key]) {
|
|
34
|
-
throw new error_1.AdapterError({ statusCode: 400, message: `No transport found for ${key}` });
|
|
35
|
-
}
|
|
36
|
-
const transport = this.transports[key];
|
|
37
|
-
logger.debug(`Found ${transport.constructor.name} corresponding to ${key}`);
|
|
38
|
-
return transport;
|
|
39
|
-
}
|
|
40
|
-
// Allow AdapterResponse<any> below since we don't know what the adapter will return
|
|
41
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
42
|
-
async foregroundExecute(req, adapterConfig) {
|
|
43
|
-
const transport = this.resolveTransport(req, adapterConfig);
|
|
44
|
-
if (transport.foregroundExecute) {
|
|
45
|
-
logger.debug(`Running foregroundExecute on retrieved transport`);
|
|
46
|
-
return transport.foregroundExecute(req, adapterConfig);
|
|
47
|
-
}
|
|
48
|
-
logger.debug(`Retrieved transport doesn't implement foregroundExecute`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.RoutingTransport = RoutingTransport;
|
|
52
|
-
//# sourceMappingURL=routing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/transports/routing.ts"],"names":[],"mappings":";;;AAEA,kCAAoC;AAGpC,+CAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,kBAAkB,CAAC,CAAA;AAE7C;;;;;;GAMG;AAEH,MAAa,gBAAgB;IAI3B;IACE,6GAA6G;IACtG,UAA0E;IAEjF,+FAA+F;IACvF,KAGG;QANJ,eAAU,GAAV,UAAU,CAAgE;QAGzE,UAAK,GAAL,KAAK,CAGF;IACV,CAAC;IAEJ,KAAK,CAAC,UAAU,CACd,YAAiC,EACjC,aAA4C,EAC5C,YAAoB;QAEpB,MAAM,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,IAAI,CA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OAAO,SAAS,CAAC,iBAAiB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;SACvD;QACD,MAAM,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAA;IACzE,CAAC;CACF;AAtDD,4CAsDC"}
|
package/transports/sse.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Cache } from '../cache';
|
|
2
|
-
import EventSource from 'eventsource';
|
|
3
|
-
import { SettingsMap, AdapterConfig } from '../config';
|
|
4
|
-
import { AxiosRequestConfig } from 'axios';
|
|
5
|
-
import { SubscriptionSet } from '../util';
|
|
6
|
-
import { AdapterRequest, AdapterResponse, ProviderResult } from '../util/request';
|
|
7
|
-
import { BackgroundStoredResultType, Transport } from './';
|
|
8
|
-
import { AdapterContext, AdapterDependencies } from '../adapter';
|
|
9
|
-
export interface SSEConfig {
|
|
10
|
-
url: string;
|
|
11
|
-
eventSourceInitDict?: EventSource.EventSourceInitDict;
|
|
12
|
-
}
|
|
13
|
-
export declare class SSETransport<AdapterParams, ProviderRequestBody, CustomSettings extends SettingsMap> implements Transport<AdapterParams, BackgroundStoredResultType, CustomSettings> {
|
|
14
|
-
private config;
|
|
15
|
-
EventSource: typeof EventSource;
|
|
16
|
-
cache: Cache<AdapterResponse<BackgroundStoredResultType>>;
|
|
17
|
-
eventListeners: {
|
|
18
|
-
type: string;
|
|
19
|
-
parseResponse: (evt: MessageEvent) => ProviderResult<AdapterParams>;
|
|
20
|
-
}[];
|
|
21
|
-
sseConnection?: EventSource;
|
|
22
|
-
subscriptionSet: SubscriptionSet<AdapterParams>;
|
|
23
|
-
timeOfLastReq: number;
|
|
24
|
-
localSubscriptions: AdapterParams[];
|
|
25
|
-
constructor(config: {
|
|
26
|
-
prepareSSEConnectionConfig: (params: AdapterParams[], context: AdapterContext<CustomSettings>) => SSEConfig;
|
|
27
|
-
prepareKeepAliveRequest: (context: AdapterContext<CustomSettings>) => AxiosRequestConfig<ProviderRequestBody>;
|
|
28
|
-
prepareSubscriptionRequest: (params: AdapterParams[], context: AdapterContext<CustomSettings>) => AxiosRequestConfig<ProviderRequestBody>;
|
|
29
|
-
prepareUnsubscriptionRequest: (params: AdapterParams[], context: AdapterContext<CustomSettings>) => AxiosRequestConfig<ProviderRequestBody>;
|
|
30
|
-
eventListeners: {
|
|
31
|
-
type: string;
|
|
32
|
-
parseResponse: (evt: MessageEvent) => ProviderResult<AdapterParams>[];
|
|
33
|
-
}[];
|
|
34
|
-
keepaliveSleepMs?: number;
|
|
35
|
-
pollingSleepMs?: number;
|
|
36
|
-
});
|
|
37
|
-
initialize(dependencies: AdapterDependencies, config: AdapterConfig<CustomSettings>, endpointName: string): Promise<void>;
|
|
38
|
-
registerRequest(req: AdapterRequest<AdapterParams>, config: AdapterConfig<CustomSettings>): Promise<void>;
|
|
39
|
-
backgroundExecute(context: AdapterContext<CustomSettings>): Promise<number>;
|
|
40
|
-
}
|
package/transports/sse.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SSETransport = void 0;
|
|
7
|
-
const eventsource_1 = __importDefault(require("eventsource"));
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const util_1 = require("../util");
|
|
10
|
-
const _1 = require("./");
|
|
11
|
-
const logger = (0, util_1.makeLogger)('SSETransport');
|
|
12
|
-
class SSETransport {
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
this.EventSource = eventsource_1.default;
|
|
16
|
-
this.timeOfLastReq = 0;
|
|
17
|
-
// The double sets serve to create a simple polling mechanism instead of needing a subscription
|
|
18
|
-
// This one would not; this is always local state
|
|
19
|
-
this.localSubscriptions = [];
|
|
20
|
-
}
|
|
21
|
-
async initialize(dependencies, config, endpointName) {
|
|
22
|
-
this.cache = dependencies.cache;
|
|
23
|
-
this.subscriptionSet = dependencies.subscriptionSetFactory.buildSet(endpointName);
|
|
24
|
-
if (dependencies.eventSource) {
|
|
25
|
-
this.EventSource = dependencies.eventSource;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async registerRequest(req, config) {
|
|
29
|
-
logger.debug(`Adding entry to subscription set (ttl: ${config.SSE_SUBSCRIPTION_TTL}): [${req.requestContext.cacheKey}] = ${req.requestContext.data}`);
|
|
30
|
-
await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data, config.SSE_SUBSCRIPTION_TTL);
|
|
31
|
-
}
|
|
32
|
-
// Unlike cache warming, this execute will manage subscriptions
|
|
33
|
-
async backgroundExecute(context) {
|
|
34
|
-
logger.debug('Starting background execute, getting subscriptions from sorted set');
|
|
35
|
-
const desiredSubs = await this.subscriptionSet.getAll();
|
|
36
|
-
logger.debug('Generating delta (subscribes & unsubscribes)');
|
|
37
|
-
const subscribeParams = desiredSubs.filter((s) => !this.localSubscriptions.includes(s));
|
|
38
|
-
const unsubscribeParams = this.localSubscriptions.filter((s) => !desiredSubs.includes(s));
|
|
39
|
-
logger.debug(`${subscribeParams.length} new subscriptions; ${unsubscribeParams.length} to unsubscribe`);
|
|
40
|
-
if (subscribeParams.length) {
|
|
41
|
-
logger.trace(`Will subscribe to: ${subscribeParams}`);
|
|
42
|
-
}
|
|
43
|
-
if (unsubscribeParams.length) {
|
|
44
|
-
logger.trace(`Will unsubscribe to: ${unsubscribeParams}`);
|
|
45
|
-
}
|
|
46
|
-
if ((subscribeParams.length || unsubscribeParams.length) &&
|
|
47
|
-
(!this.sseConnection || this.sseConnection.readyState !== this.sseConnection.OPEN)) {
|
|
48
|
-
logger.debug('No established connection and new subscriptions available, connecting to SSE');
|
|
49
|
-
const sseConfig = this.config.prepareSSEConnectionConfig(subscribeParams, context);
|
|
50
|
-
this.sseConnection = new this.EventSource(sseConfig.url, sseConfig.eventSourceInitDict);
|
|
51
|
-
const eventHandlerGenerator = (listener) => {
|
|
52
|
-
return (e) => {
|
|
53
|
-
const providerResponses = listener.parseResponse(e);
|
|
54
|
-
const cacheEntries = (0, _1.buildCacheEntriesFromResults)(providerResponses, context);
|
|
55
|
-
this.cache.setMany(cacheEntries, context.adapterConfig.CACHE_MAX_AGE);
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
this.config.eventListeners.forEach((listener) => {
|
|
59
|
-
this.sseConnection?.addEventListener(listener.type, eventHandlerGenerator(listener));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const makeRequest = async (req) => {
|
|
63
|
-
try {
|
|
64
|
-
const res = await axios_1.default.request(req);
|
|
65
|
-
logger.debug(res.data, `response status ${res.statusText} from keepalive request`);
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
logger.error(err, `Error on keepalive request`);
|
|
69
|
-
}
|
|
70
|
-
this.timeOfLastReq = Date.now();
|
|
71
|
-
};
|
|
72
|
-
if (subscribeParams.length) {
|
|
73
|
-
const subscribeRequest = this.config.prepareSubscriptionRequest(subscribeParams, context);
|
|
74
|
-
makeRequest(subscribeRequest);
|
|
75
|
-
}
|
|
76
|
-
if (unsubscribeParams.length) {
|
|
77
|
-
const unsubscribeRequest = this.config.prepareUnsubscriptionRequest(unsubscribeParams, context);
|
|
78
|
-
makeRequest(unsubscribeRequest);
|
|
79
|
-
}
|
|
80
|
-
if (desiredSubs.length &&
|
|
81
|
-
Date.now() - this.timeOfLastReq > context.adapterConfig.SSE_KEEPALIVE_SLEEP) {
|
|
82
|
-
const prepareKeepAliveRequest = this.config.prepareKeepAliveRequest(context);
|
|
83
|
-
makeRequest(prepareKeepAliveRequest);
|
|
84
|
-
}
|
|
85
|
-
logger.debug('Setting local state to cache value');
|
|
86
|
-
this.localSubscriptions = desiredSubs;
|
|
87
|
-
logger.debug('Background execute complete');
|
|
88
|
-
return context.adapterConfig.SSE_SUBSCRIPTION_UPDATE_SLEEP;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.SSETransport = SSETransport;
|
|
92
|
-
//# sourceMappingURL=sse.js.map
|
package/transports/sse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/transports/sse.ts"],"names":[],"mappings":";;;;;;AACA,8DAAqC;AAErC,kDAAiD;AACjD,kCAAqD;AAErD,yBAAwF;AAGxF,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,cAAc,CAAC,CAAA;AAOzC,MAAa,YAAY;IAiBvB,YACU,MAsBP;QAtBO,WAAM,GAAN,MAAM,CAsBb;QArCH,gBAAW,GAAuB,qBAAW,CAAA;QAQ7C,kBAAa,GAAG,CAAC,CAAA;QAEjB,+FAA+F;QAC/F,iDAAiD;QACjD,uBAAkB,GAAoB,EAAE,CAAA;IA0BrC,CAAC;IAEJ,KAAK,CAAC,UAAU,CACd,YAAiC,EACjC,MAAqC,EACrC,YAAoB;QAEpB,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAA2D,CAAA;QACrF,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,sBAAsB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;QACjF,IAAI,YAAY,CAAC,WAAW,EAAE;YAC5B,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC,WAAW,CAAA;SAC5C;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,GAAkC,EAClC,MAAqC;QAErC,MAAM,CAAC,KAAK,CACV,0CAA0C,MAAM,CAAC,oBAAoB,OAAO,GAAG,CAAC,cAAc,CAAC,QAAQ,OAAO,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CACxI,CAAA;QACD,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAC5B,GAAG,CAAC,cAAc,CAAC,QAAQ,EAC3B,GAAG,CAAC,cAAc,CAAC,IAAI,EACvB,MAAM,CAAC,oBAAoB,CAC5B,CAAA;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AC,gBAAgB,CAAC,CAAA;SAC9B;QACD,IAAI,iBAAiB,CAAC,MAAM,EAAE;YAC5B,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,4BAA4B,CACjE,iBAAiB,EACjB,OAAO,CACR,CAAA;YACD,WAAW,CAAC,kBAAkB,CAAC,CAAA;SAChC;QACD,IACE,WAAW,CAAC,MAAM;YAClB,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,mBAAmB,EAC3E;YACA,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAA;YAC5E,WAAW,CAAC,uBAAuB,CAAC,CAAA;SACrC;QAED,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAClD,IAAI,CAAC,kBAAkB,GAAG,WAAW,CAAA;QAErC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC3C,OAAO,OAAO,CAAC,aAAa,CAAC,6BAA6B,CAAA;IAC5D,CAAC;CACF;AAhJD,oCAgJC"}
|
package/transports/util.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { AdapterConfig, SettingsMap } from '../config';
|
|
3
|
-
/**
|
|
4
|
-
* Performs axios request along with metrics recording and error handling
|
|
5
|
-
*
|
|
6
|
-
* @param request - axios request config
|
|
7
|
-
* @returns axios response for the request
|
|
8
|
-
*/
|
|
9
|
-
export declare function axiosRequest<ProviderRequestBody, ProviderResponseBody, CustomSettings extends SettingsMap>(request: AxiosRequestConfig<ProviderRequestBody>, config: AdapterConfig<CustomSettings>): Promise<AxiosResponse<ProviderResponseBody>>;
|
package/transports/util.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.axiosRequest = void 0;
|
|
30
|
-
const axios_1 = __importDefault(require("axios"));
|
|
31
|
-
const error_1 = require("../validation/error");
|
|
32
|
-
const transportMetrics = __importStar(require("./metrics"));
|
|
33
|
-
/**
|
|
34
|
-
* Performs axios request along with metrics recording and error handling
|
|
35
|
-
*
|
|
36
|
-
* @param request - axios request config
|
|
37
|
-
* @returns axios response for the request
|
|
38
|
-
*/
|
|
39
|
-
async function axiosRequest(request, config) {
|
|
40
|
-
const responseTimer = transportMetrics.dataProviderRequestDurationSeconds.startTimer();
|
|
41
|
-
let providerResponse;
|
|
42
|
-
try {
|
|
43
|
-
request.timeout = config.API_TIMEOUT;
|
|
44
|
-
providerResponse = await axios_1.default.request(request);
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
const error = e;
|
|
48
|
-
// Request error
|
|
49
|
-
let providerStatusCode;
|
|
50
|
-
let adapterError;
|
|
51
|
-
if (error.code === 'ECONNABORTED') {
|
|
52
|
-
adapterError = new error_1.AdapterTimeoutError({});
|
|
53
|
-
providerStatusCode = error?.response?.status ?? 504;
|
|
54
|
-
adapterError.name = 'Data Provider Request Timeout error';
|
|
55
|
-
}
|
|
56
|
-
else if (error?.response?.status) {
|
|
57
|
-
adapterError = new error_1.AdapterDataProviderError({});
|
|
58
|
-
providerStatusCode = error?.response?.status;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
adapterError = new error_1.AdapterConnectionError({});
|
|
62
|
-
providerStatusCode = 0; // 0 -> connection error
|
|
63
|
-
}
|
|
64
|
-
// Record count of failed data provider request
|
|
65
|
-
transportMetrics.dataProviderRequests
|
|
66
|
-
.labels(transportMetrics.dataProviderMetricsLabel(providerStatusCode, request.method))
|
|
67
|
-
.inc();
|
|
68
|
-
adapterError.statusCode = 200;
|
|
69
|
-
adapterError.providerStatusCode = providerStatusCode;
|
|
70
|
-
adapterError.message = error?.message;
|
|
71
|
-
adapterError.cause = error;
|
|
72
|
-
adapterError.errorResponse = error?.response?.data;
|
|
73
|
-
adapterError.url = request.url;
|
|
74
|
-
throw adapterError;
|
|
75
|
-
}
|
|
76
|
-
finally {
|
|
77
|
-
// Record time taken for data provider request for success or failure
|
|
78
|
-
responseTimer();
|
|
79
|
-
}
|
|
80
|
-
// Record count of successful data provider requests
|
|
81
|
-
transportMetrics.dataProviderRequests
|
|
82
|
-
.labels(transportMetrics.dataProviderMetricsLabel(providerResponse.status, request.method))
|
|
83
|
-
.inc();
|
|
84
|
-
return providerResponse;
|
|
85
|
-
}
|
|
86
|
-
exports.axiosRequest = axiosRequest;
|
|
87
|
-
//# sourceMappingURL=util.js.map
|
package/transports/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/transports/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4E;AAE5E,+CAK4B;AAC5B,4DAA6C;AAE7C;;;;;GAKG;AACI,KAAK,UAAU,YAAY,CAKhC,OAAgD,EAChD,MAAqC;IAErC,MAAM,aAAa,GAAG,gBAAgB,CAAC,kCAAkC,CAAC,UAAU,EAAE,CAAA;IACtF,IAAI,gBAAqD,CAAA;IACzD,IAAI;QACF,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAA;QACpC,gBAAgB,GAAG,MAAM,eAAK,CAAC,OAAO,CAAuB,OAAO,CAAC,CAAA;KACtE;IAAC,OAAO,CAAU,EAAE;QACnB,MAAM,KAAK,GAAG,CAAe,CAAA;QAC7B,gBAAgB;QAChB,IAAI,kBAAsC,CAAA;QAC1C,IAAI,YAA0B,CAAA;QAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE;YACjC,YAAY,GAAG,IAAI,2BAAmB,CAAC,EAAE,CAAC,CAAA;YAC1C,kBAAkB,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,CAAA;YACnD,YAAY,CAAC,IAAI,GAAG,qCAAqC,CAAA;SAC1D;aAAM,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE;YAClC,YAAY,GAAG,IAAI,gCAAwB,CAAC,EAAE,CAAC,CAAA;YAC/C,kBAAkB,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAA;SAC7C;aAAM;YACL,YAAY,GAAG,IAAI,8BAAsB,CAAC,EAAE,CAAC,CAAA;YAC7C,kBAAkB,GAAG,CAAC,CAAA,CAAC,wBAAwB;SAChD;QACD,+CAA+C;QAC/C,gBAAgB,CAAC,oBAAoB;aAClC,MAAM,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;aACrF,GAAG,EAAE,CAAA;QAER,YAAY,CAAC,UAAU,GAAG,GAAG,CAAA;QAC7B,YAAY,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QACpD,YAAY,CAAC,OAAO,GAAG,KAAK,EAAE,OAAO,CAAA;QACrC,YAAY,CAAC,KAAK,GAAG,KAAK,CAAA;QAC1B,YAAY,CAAC,aAAa,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAA;QAClD,YAAY,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QAE9B,MAAM,YAAY,CAAA;KACnB;YAAS;QACR,qEAAqE;QACrE,aAAa,EAAE,CAAA;KAChB;IAED,oDAAoD;IACpD,gBAAgB,CAAC,oBAAoB;SAClC,MAAM,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;SAC1F,GAAG,EAAE,CAAA;IAER,OAAO,gBAAgB,CAAA;AACzB,CAAC;AArDD,oCAqDC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import WebSocket, { ClientOptions, RawData } from 'ws';
|
|
2
|
-
import { AdapterContext, AdapterDependencies } from '../adapter';
|
|
3
|
-
import { Cache } from '../cache';
|
|
4
|
-
import { AdapterConfig, SettingsMap } from '../config';
|
|
5
|
-
import { BackgroundExecuteRateLimiter } from '../rate-limiting';
|
|
6
|
-
import { SubscriptionSet } from '../util';
|
|
7
|
-
import { AdapterRequest, AdapterResponse, ProviderResult } from '../util/request';
|
|
8
|
-
import { Transport, BackgroundStoredResultType } from './';
|
|
9
|
-
export { WebSocket, RawData as WebSocketRawData };
|
|
10
|
-
declare type WebSocketClass = new (url: string, protocols?: string | string[] | undefined, options?: ClientOptions) => WebSocket;
|
|
11
|
-
export declare class WebSocketClassProvider {
|
|
12
|
-
static ctor: WebSocketClass;
|
|
13
|
-
static set(ctor: WebSocketClass): void;
|
|
14
|
-
static get(): WebSocketClass;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Config object that is provided to the WebSocketTransport constructor.
|
|
18
|
-
*/
|
|
19
|
-
export interface WebSocketTransportConfig<AdapterParams, ProviderDataMessage, CustomSettings extends SettingsMap> {
|
|
20
|
-
/** Endpoint to which to open the WS connection*/
|
|
21
|
-
url: (context: AdapterContext<CustomSettings>) => string;
|
|
22
|
-
/** Optional parameters used when establishing the WebSocket connection */
|
|
23
|
-
options?: (context: AdapterContext<CustomSettings>) => ClientOptions;
|
|
24
|
-
/** Map of handlers for different WS lifecycle events */
|
|
25
|
-
handlers: {
|
|
26
|
-
/**
|
|
27
|
-
* Handles when the WS is successfully opened
|
|
28
|
-
*
|
|
29
|
-
* @param wsConnection - the WebSocket with an established connection
|
|
30
|
-
* @returns an empty Promise, or void
|
|
31
|
-
*/
|
|
32
|
-
open: (wsConnection: WebSocket, context: AdapterContext<CustomSettings>) => Promise<void> | void;
|
|
33
|
-
/**
|
|
34
|
-
* Handles when the WS receives a message
|
|
35
|
-
*
|
|
36
|
-
* @param message - the message received by the WS
|
|
37
|
-
* @param context - the background context for the Adapter
|
|
38
|
-
* @returns a list of cache entries of adapter responses to set in the cache
|
|
39
|
-
*/
|
|
40
|
-
message: (message: ProviderDataMessage, context: AdapterContext<CustomSettings>) => ProviderResult<AdapterParams>[] | undefined;
|
|
41
|
-
};
|
|
42
|
-
/** Map of "builders", functions that will be used to prepare specific WS messages */
|
|
43
|
-
builders: {
|
|
44
|
-
/**
|
|
45
|
-
* Builds a WS message that will be sent to subscribe to a specific feed
|
|
46
|
-
*
|
|
47
|
-
* @param params - the body of the adapter request
|
|
48
|
-
* @returns the WS message (can be any type as long as the [[WebSocket]] doesn't complain)
|
|
49
|
-
*/
|
|
50
|
-
subscribeMessage: (params: AdapterParams) => unknown;
|
|
51
|
-
/**
|
|
52
|
-
* Builds a WS message that will be sent to unsubscribe to a specific feed
|
|
53
|
-
*
|
|
54
|
-
* @param params - the body of the adapter request
|
|
55
|
-
* @returns the WS message (can be any type as long as the [[WebSocket]] doesn't complain)
|
|
56
|
-
*/
|
|
57
|
-
unsubscribeMessage: (params: AdapterParams) => unknown;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Transport implementation that takes incoming requests, adds them to an [[subscriptionSet]] and,
|
|
62
|
-
* through a WebSocket connection, subscribes to the relevant feeds to populate the cache.
|
|
63
|
-
*
|
|
64
|
-
* @typeParam AdapterParams - interface for the adapter request body
|
|
65
|
-
* @typeParam ProviderDataMessage - interface for a WS message containing processable data (i.e. not part of open/close/login/etc)
|
|
66
|
-
*/
|
|
67
|
-
export declare class WebSocketTransport<AdapterParams, ProviderDataMessage, CustomSettings extends SettingsMap> implements Transport<AdapterParams, BackgroundStoredResultType, CustomSettings> {
|
|
68
|
-
private config;
|
|
69
|
-
cache: Cache<AdapterResponse<BackgroundStoredResultType>>;
|
|
70
|
-
rateLimiter: BackgroundExecuteRateLimiter;
|
|
71
|
-
subscriptionSet: SubscriptionSet<AdapterParams>;
|
|
72
|
-
localSubscriptions: AdapterParams[];
|
|
73
|
-
wsConnection: WebSocket;
|
|
74
|
-
constructor(config: WebSocketTransportConfig<AdapterParams, ProviderDataMessage, CustomSettings>);
|
|
75
|
-
initialize(dependencies: AdapterDependencies, config: AdapterConfig<CustomSettings>, endpointName: string): Promise<void>;
|
|
76
|
-
registerRequest(req: AdapterRequest<AdapterParams>, config: AdapterConfig<CustomSettings>): Promise<void>;
|
|
77
|
-
serializeMessage(payload: unknown): string;
|
|
78
|
-
deserializeMessage(data: WebSocket.Data): ProviderDataMessage;
|
|
79
|
-
establishWsConnection(context: AdapterContext<CustomSettings>): Promise<unknown>;
|
|
80
|
-
backgroundExecute(context: AdapterContext<CustomSettings>): Promise<number>;
|
|
81
|
-
}
|
package/transports/websocket.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.WebSocketTransport = exports.WebSocketClassProvider = exports.WebSocket = void 0;
|
|
30
|
-
const ws_1 = __importDefault(require("ws"));
|
|
31
|
-
exports.WebSocket = ws_1.default;
|
|
32
|
-
const util_1 = require("../util");
|
|
33
|
-
const _1 = require("./");
|
|
34
|
-
const transportMetrics = __importStar(require("./metrics"));
|
|
35
|
-
const logger = (0, util_1.makeLogger)('WebSocketTransport');
|
|
36
|
-
class WebSocketClassProvider {
|
|
37
|
-
static set(ctor) {
|
|
38
|
-
this.ctor = ctor;
|
|
39
|
-
}
|
|
40
|
-
static get() {
|
|
41
|
-
return this.ctor;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.WebSocketClassProvider = WebSocketClassProvider;
|
|
45
|
-
WebSocketClassProvider.ctor = ws_1.default;
|
|
46
|
-
/**
|
|
47
|
-
* Transport implementation that takes incoming requests, adds them to an [[subscriptionSet]] and,
|
|
48
|
-
* through a WebSocket connection, subscribes to the relevant feeds to populate the cache.
|
|
49
|
-
*
|
|
50
|
-
* @typeParam AdapterParams - interface for the adapter request body
|
|
51
|
-
* @typeParam ProviderDataMessage - interface for a WS message containing processable data (i.e. not part of open/close/login/etc)
|
|
52
|
-
*/
|
|
53
|
-
class WebSocketTransport {
|
|
54
|
-
constructor(config) {
|
|
55
|
-
this.config = config;
|
|
56
|
-
// The double sets serve to create a simple polling mechanism instead of needing a subscription
|
|
57
|
-
// This one would not; this is always local state
|
|
58
|
-
this.localSubscriptions = [];
|
|
59
|
-
}
|
|
60
|
-
async initialize(dependencies, config, endpointName) {
|
|
61
|
-
this.cache = dependencies.cache;
|
|
62
|
-
this.rateLimiter = dependencies.backgroundExecuteRateLimiter;
|
|
63
|
-
this.subscriptionSet = dependencies.subscriptionSetFactory.buildSet(endpointName);
|
|
64
|
-
}
|
|
65
|
-
async registerRequest(req, config) {
|
|
66
|
-
logger.debug(`Adding entry to subscription set (ttl: ${config.WS_SUBSCRIPTION_TTL}): [${req.requestContext.cacheKey}] = ${req.requestContext.data}`);
|
|
67
|
-
await this.subscriptionSet.add(req.requestContext.cacheKey, req.requestContext.data, config.WS_SUBSCRIPTION_TTL);
|
|
68
|
-
}
|
|
69
|
-
serializeMessage(payload) {
|
|
70
|
-
return typeof payload === 'string' ? payload : JSON.stringify(payload);
|
|
71
|
-
}
|
|
72
|
-
deserializeMessage(data) {
|
|
73
|
-
return JSON.parse(data.toString());
|
|
74
|
-
}
|
|
75
|
-
establishWsConnection(context) {
|
|
76
|
-
return new Promise((resolve) => {
|
|
77
|
-
const ctor = WebSocketClassProvider.get();
|
|
78
|
-
const url = context.adapterConfig.WS_API_ENDPOINT || this.config.url(context);
|
|
79
|
-
const options = this.config.options && this.config.options(context);
|
|
80
|
-
this.wsConnection = new ctor(url, undefined, options);
|
|
81
|
-
this.wsConnection.addEventListener('open', async (event) => {
|
|
82
|
-
logger.debug(`Opened websocket connection. (event type ${event.type})`);
|
|
83
|
-
await this.config.handlers.open(this.wsConnection, context);
|
|
84
|
-
logger.debug('Successfully executed connection opened handler');
|
|
85
|
-
// Record active ws connections by incrementing count on open
|
|
86
|
-
transportMetrics.wsConnectionActive.inc();
|
|
87
|
-
resolve(true);
|
|
88
|
-
});
|
|
89
|
-
this.wsConnection.addEventListener('message', async (event) => {
|
|
90
|
-
const parsed = this.deserializeMessage(event.data);
|
|
91
|
-
logger.trace(`Got ws message: ${parsed}`);
|
|
92
|
-
const results = this.config.handlers.message(parsed, context);
|
|
93
|
-
if (Array.isArray(results)) {
|
|
94
|
-
const responses = (0, _1.buildCacheEntriesFromResults)(results, context);
|
|
95
|
-
logger.trace(`Writing ${responses.length} responses to cache`);
|
|
96
|
-
await this.cache.setMany(responses, context.adapterConfig.CACHE_MAX_AGE);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
this.wsConnection.addEventListener('error', async (event) => {
|
|
100
|
-
logger.debug(`Error occurred in web socket connection. Error: ${event.error} ; Message: ${event.message}`);
|
|
101
|
-
// Record connection error count
|
|
102
|
-
transportMetrics.wsConnectionErrors
|
|
103
|
-
.labels(transportMetrics.connectionErrorLabels(event.message))
|
|
104
|
-
.inc();
|
|
105
|
-
});
|
|
106
|
-
this.wsConnection.addEventListener('close', (event) => {
|
|
107
|
-
logger.debug(`Closed websocket connection. Code: ${event.code} ; reason: ${event.reason?.toString()}`);
|
|
108
|
-
// Record active ws connections by decrementing count on close
|
|
109
|
-
// Using URL in label since connection_key is removed from v3
|
|
110
|
-
transportMetrics.wsConnectionActive.dec();
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
// Unlike cache warming, this execute will manage subscriptions
|
|
115
|
-
async backgroundExecute(context) {
|
|
116
|
-
logger.debug('Starting background execute, getting subscriptions from sorted set');
|
|
117
|
-
const desiredSubs = await this.subscriptionSet.getAll();
|
|
118
|
-
// Keep track of active subscriptions for background execute
|
|
119
|
-
transportMetrics.bgExecuteSubscriptionSetCount
|
|
120
|
-
.labels({ endpoint: context.adapterEndpoint.name, transport_type: 'websocket' })
|
|
121
|
-
.set(desiredSubs.length);
|
|
122
|
-
logger.debug('Generating delta (subscribes & unsubscribes)');
|
|
123
|
-
const subscribeParams = desiredSubs.filter((s) => !this.localSubscriptions.map((ls) => JSON.stringify(ls)).includes(JSON.stringify(s)));
|
|
124
|
-
const subscribes = subscribeParams
|
|
125
|
-
.map(this.config.builders.subscribeMessage)
|
|
126
|
-
.map(this.serializeMessage);
|
|
127
|
-
const unsubscribeParams = this.localSubscriptions.filter((s) => !desiredSubs.map((ds) => JSON.stringify(ds)).includes(JSON.stringify(s)));
|
|
128
|
-
const unsubscribes = unsubscribeParams
|
|
129
|
-
.map(this.config.builders.unsubscribeMessage)
|
|
130
|
-
.map(this.serializeMessage);
|
|
131
|
-
logger.debug(`${subscribes.length} new subscriptions; ${unsubscribes.length} to unsubscribe`);
|
|
132
|
-
if (subscribes.length) {
|
|
133
|
-
logger.trace(`Will subscribe to: ${subscribes}`);
|
|
134
|
-
}
|
|
135
|
-
if (unsubscribes.length) {
|
|
136
|
-
logger.trace(`Will unsubscribe to: ${unsubscribes}`);
|
|
137
|
-
}
|
|
138
|
-
// New subs && no connection -> connect -> add subs
|
|
139
|
-
// No new subs && no connection -> skip
|
|
140
|
-
// New subs && connection -> add subs
|
|
141
|
-
// No new subs && connection -> unsubs only
|
|
142
|
-
if (!subscribes.length && !this.wsConnection) {
|
|
143
|
-
logger.debug('No entries in subscription set and no established connection, skipping');
|
|
144
|
-
return this.rateLimiter.msUntilNextExecution(context.adapterEndpoint.name);
|
|
145
|
-
}
|
|
146
|
-
if (!this.wsConnection && subscribes.length) {
|
|
147
|
-
logger.debug('No established connection and new subscriptions available, connecting to WS');
|
|
148
|
-
await this.establishWsConnection(context);
|
|
149
|
-
}
|
|
150
|
-
logger.debug('Sending subs/unsubs if there are any');
|
|
151
|
-
const messages = unsubscribes.concat(subscribes);
|
|
152
|
-
for (const message of messages) {
|
|
153
|
-
logger.trace(`Sending message: ${JSON.stringify(message)}`);
|
|
154
|
-
this.wsConnection.send(message);
|
|
155
|
-
}
|
|
156
|
-
// Record WS message and subscription metrics
|
|
157
|
-
transportMetrics.recordWsMessageMetrics(context, subscribeParams, unsubscribeParams);
|
|
158
|
-
logger.debug('Setting local state to cache value');
|
|
159
|
-
this.localSubscriptions = desiredSubs;
|
|
160
|
-
logger.debug('Background execute complete');
|
|
161
|
-
return this.rateLimiter.msUntilNextExecution(context.adapterEndpoint.name);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
exports.WebSocketTransport = WebSocketTransport;
|
|
165
|
-
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/transports/websocket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAsD;AAW7C,oBAXF,YAAS,CAWE;AANlB,kCAAqD;AAErD,yBAAwF;AACxF,4DAA6C;AAK7C,MAAM,MAAM,GAAG,IAAA,iBAAU,EAAC,oBAAoB,CAAC,CAAA;AAQ/C,MAAa,sBAAsB;IAGjC,MAAM,CAAC,GAAG,CAAC,IAAoB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;;AATH,wDAU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A+JC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class CensorList {
|
|
4
|
-
static getAll() {
|
|
5
|
-
return this.censorList;
|
|
6
|
-
}
|
|
7
|
-
static set(censorList) {
|
|
8
|
-
this.censorList = censorList;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = CensorList;
|
|
12
|
-
CensorList.censorList = [];
|
|
13
|
-
//# sourceMappingURL=censor-list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"censor-list.js","sourceRoot":"","sources":["../../../../src/util/censor/censor-list.ts"],"names":[],"mappings":";;AAAA,MAAqB,UAAU;IAE7B,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,UAA4B;QACrC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;;AAPH,6BAQC;AAPQ,qBAAU,GAAqB,EAAE,CAAA"}
|
package/util/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './request';
|
|
2
|
-
export * from './logger';
|
|
3
|
-
export * from './subscription-set/subscription-set';
|
|
4
|
-
/**
|
|
5
|
-
* Sleeps for the provided number of milliseconds
|
|
6
|
-
* @param ms - The number of milliseconds to sleep for
|
|
7
|
-
* @returns a Promise that resolves once the specified time passes
|
|
8
|
-
*/
|
|
9
|
-
export declare const sleep: (ms: number) => Promise<void>;
|
|
10
|
-
export declare const isObject: (o: unknown) => boolean;
|
|
11
|
-
export declare const isArray: (o: unknown) => boolean;
|
|
12
|
-
export declare const isEmpty: (o: unknown) => boolean;
|
|
13
|
-
export declare type PromiseOrValue<T> = Promise<T> | T;
|