@chainlink/external-adapter-framework 0.0.15 → 0.0.16
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/adapter.js +128 -0
- package/background-executor.js +45 -0
- package/cache/factory.js +58 -0
- package/cache/index.js +173 -0
- package/cache/local.js +83 -0
- package/cache/metrics.js +120 -0
- package/cache/redis.js +100 -0
- package/chainlink-external-adapter-framework-v0.0.6.tgz +0 -0
- package/config/index.js +366 -0
- package/config/provider-limits.js +74 -0
- package/examples/bank-frick/accounts.js +192 -0
- package/examples/bank-frick/config/index.js +54 -0
- package/examples/bank-frick/index.js +15 -0
- package/examples/bank-frick/util.js +39 -0
- package/examples/coingecko/src/config/index.js +13 -0
- package/examples/coingecko/src/config/overrides.json +10826 -0
- package/examples/coingecko/src/cryptoUtils.js +41 -0
- package/examples/coingecko/src/endpoint/coins.js +33 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +46 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js +46 -0
- package/examples/coingecko/src/endpoint/crypto.js +47 -0
- package/examples/coingecko/src/endpoint/dominance.js +26 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js +26 -0
- package/examples/coingecko/src/endpoint/index.js +15 -0
- package/examples/coingecko/src/globalUtils.js +48 -0
- package/examples/coingecko/src/index.js +14 -0
- package/examples/coingecko/test/e2e/adapter.test.js +262 -0
- package/examples/coingecko/test/integration/adapter.test.js +264 -0
- package/examples/coingecko/test/integration/capturedRequests.json +1 -0
- package/examples/coingecko/test/integration/fixtures.js +41 -0
- package/examples/coingecko-old/batch-warming.js +53 -0
- package/examples/coingecko-old/index.js +11 -0
- package/examples/coingecko-old/rest.js +51 -0
- package/examples/ncfx/config/index.js +15 -0
- package/examples/ncfx/index.js +11 -0
- package/examples/ncfx/websocket.js +73 -0
- package/index.js +127 -0
- package/metrics/constants.js +25 -0
- package/metrics/index.js +122 -0
- package/metrics/util.js +9 -0
- package/package.json +5 -15
- package/rate-limiting/background/fixed-frequency.js +35 -0
- package/rate-limiting/index.js +84 -0
- package/rate-limiting/metrics.js +44 -0
- package/rate-limiting/request/simple-counting.js +62 -0
- package/test.js +6 -0
- package/transports/batch-warming.js +101 -0
- package/transports/index.js +87 -0
- package/transports/metrics.js +105 -0
- package/transports/rest.js +138 -0
- package/transports/util.js +86 -0
- package/transports/websocket.js +166 -0
- package/util/index.js +35 -0
- package/util/logger.js +62 -0
- package/util/recordRequests.js +45 -0
- package/util/request.js +2 -0
- package/util/subscription-set/expiring-sorted-set.js +47 -0
- package/util/subscription-set/subscription-set.js +19 -0
- package/util/test-payload-loader.js +83 -0
- package/validation/error.js +79 -0
- package/validation/index.js +91 -0
- package/validation/input-params.js +30 -0
- package/validation/override-functions.js +40 -0
- package/validation/overrideFunctions.js +40 -0
- package/validation/preset-tokens.json +23 -0
- package/validation/validator.js +303 -0
- package/.c8rc.json +0 -3
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -96
- package/.github/README.MD +0 -42
- package/.github/actions/setup/action.yaml +0 -13
- package/.github/workflows/label.yaml +0 -39
- package/.github/workflows/main.yaml +0 -39
- package/.github/workflows/publish.yaml +0 -17
- package/.prettierignore +0 -13
- package/.yarnrc +0 -0
- package/README.md +0 -103
- package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +0 -82953
- package/dist/examples/coingecko/test/integration/adapter.test.ts.js +0 -91672
- package/dist/main.js +0 -72703
- package/docker-compose.yaml +0 -35
- package/env.sh +0 -54
- package/env2.sh +0 -55
- package/jest.config.js +0 -5
- package/publish.sh +0 -0
- package/src/adapter.ts +0 -263
- package/src/background-executor.ts +0 -52
- package/src/cache/factory.ts +0 -26
- package/src/cache/index.ts +0 -258
- package/src/cache/local.ts +0 -73
- package/src/cache/metrics.ts +0 -112
- package/src/cache/redis.ts +0 -93
- package/src/config/index.ts +0 -517
- package/src/config/provider-limits.ts +0 -127
- package/src/examples/bank-frick/README.MD +0 -10
- package/src/examples/bank-frick/accounts.ts +0 -246
- package/src/examples/bank-frick/config/index.ts +0 -53
- package/src/examples/bank-frick/index.ts +0 -13
- package/src/examples/bank-frick/types.d.ts +0 -38
- package/src/examples/bank-frick/util.ts +0 -55
- package/src/examples/coingecko/src/config/index.ts +0 -12
- package/src/examples/coingecko/src/config/overrides.json +0 -10826
- package/src/examples/coingecko/src/cryptoUtils.ts +0 -88
- package/src/examples/coingecko/src/endpoint/coins.ts +0 -54
- package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +0 -66
- package/src/examples/coingecko/src/endpoint/crypto-volume.ts +0 -66
- package/src/examples/coingecko/src/endpoint/crypto.ts +0 -63
- package/src/examples/coingecko/src/endpoint/dominance.ts +0 -40
- package/src/examples/coingecko/src/endpoint/global-marketcap.ts +0 -40
- package/src/examples/coingecko/src/endpoint/index.ts +0 -6
- package/src/examples/coingecko/src/globalUtils.ts +0 -78
- package/src/examples/coingecko/src/index.ts +0 -17
- package/src/examples/coingecko/test/e2e/adapter.test.ts +0 -278
- package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +0 -15
- package/src/examples/coingecko/test/integration/adapter.test.ts +0 -281
- package/src/examples/coingecko/test/integration/capturedRequests.json +0 -1
- package/src/examples/coingecko/test/integration/fixtures.ts +0 -42
- package/src/examples/coingecko-old/batch-warming.ts +0 -79
- package/src/examples/coingecko-old/index.ts +0 -9
- package/src/examples/coingecko-old/rest.ts +0 -77
- package/src/examples/ncfx/config/index.ts +0 -12
- package/src/examples/ncfx/index.ts +0 -9
- package/src/examples/ncfx/websocket.ts +0 -99
- package/src/index.ts +0 -149
- package/src/metrics/constants.ts +0 -23
- package/src/metrics/index.ts +0 -115
- package/src/metrics/util.ts +0 -18
- package/src/rate-limiting/background/fixed-frequency.ts +0 -45
- package/src/rate-limiting/index.ts +0 -100
- package/src/rate-limiting/metrics.ts +0 -18
- package/src/rate-limiting/request/simple-counting.ts +0 -76
- package/src/transports/batch-warming.ts +0 -127
- package/src/transports/index.ts +0 -152
- package/src/transports/metrics.ts +0 -95
- package/src/transports/rest.ts +0 -168
- package/src/transports/util.ts +0 -63
- package/src/transports/websocket.ts +0 -245
- package/src/util/index.ts +0 -23
- package/src/util/logger.ts +0 -69
- package/src/util/recordRequests.ts +0 -47
- package/src/util/request.ts +0 -117
- package/src/util/subscription-set/expiring-sorted-set.ts +0 -54
- package/src/util/subscription-set/subscription-set.ts +0 -35
- package/src/util/test-payload-loader.ts +0 -87
- package/src/validation/error.ts +0 -116
- package/src/validation/index.ts +0 -110
- package/src/validation/input-params.ts +0 -45
- package/src/validation/override-functions.ts +0 -44
- package/src/validation/overrideFunctions.ts +0 -44
- package/src/validation/preset-tokens.json +0 -23
- package/src/validation/validator.ts +0 -384
- package/test/adapter.test.ts +0 -27
- package/test/background-executor.test.ts +0 -108
- package/test/cache/cache-key.test.ts +0 -114
- package/test/cache/helper.ts +0 -100
- package/test/cache/local.test.ts +0 -54
- package/test/cache/redis.test.ts +0 -89
- package/test/correlation.test.ts +0 -114
- package/test/index.test.ts +0 -37
- package/test/metrics/feed-id.test.ts +0 -38
- package/test/metrics/helper.ts +0 -14
- package/test/metrics/labels.test.ts +0 -36
- package/test/metrics/metrics.test.ts +0 -267
- package/test/metrics/redis-metrics.test.ts +0 -113
- package/test/metrics/warmer-metrics.test.ts +0 -193
- package/test/metrics/ws-metrics.test.ts +0 -225
- package/test/rate-limit-config.test.ts +0 -242
- package/test/smoke/smoke.test.ts +0 -166
- package/test/smoke/test-payload-fail.json +0 -3
- package/test/smoke/test-payload.js +0 -22
- package/test/smoke/test-payload.json +0 -7
- package/test/transports/batch.test.ts +0 -466
- package/test/transports/rest.test.ts +0 -242
- package/test/transports/websocket.test.ts +0 -183
- package/test/tsconfig.json +0 -5
- package/test/util.ts +0 -77
- package/test/validation.test.ts +0 -178
- package/test.sh +0 -20
- package/test2.sh +0 -2
- package/tsconfig.json +0 -28
- package/typedoc.json +0 -6
- package/webpack.config.js +0 -57
- package/yarn-error.log +0 -3778
package/docker-compose.yaml
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Very basic stack to demonstrate horizontal scaling
|
|
2
|
-
services:
|
|
3
|
-
redis:
|
|
4
|
-
image: redis
|
|
5
|
-
container_name: redis
|
|
6
|
-
|
|
7
|
-
coingecko-reader:
|
|
8
|
-
image: node:alpine
|
|
9
|
-
ports:
|
|
10
|
-
- 8080
|
|
11
|
-
deploy:
|
|
12
|
-
mode: replicated
|
|
13
|
-
replicas: 2
|
|
14
|
-
environment:
|
|
15
|
-
- DISABLE_BACKGROUND_EXECUTOR=true
|
|
16
|
-
volumes:
|
|
17
|
-
- ./:/home/node/app
|
|
18
|
-
command: node /home/node/app/dist/test.js
|
|
19
|
-
|
|
20
|
-
coingecko-writer:
|
|
21
|
-
image: node:alpine
|
|
22
|
-
volumes:
|
|
23
|
-
- ./:/home/node/app
|
|
24
|
-
environment:
|
|
25
|
-
- DISABLE_REST_API=true
|
|
26
|
-
command: node /home/node/app/dist/test.js
|
|
27
|
-
|
|
28
|
-
lb:
|
|
29
|
-
image: dockercloud/haproxy
|
|
30
|
-
links:
|
|
31
|
-
- coingecko-reader
|
|
32
|
-
ports:
|
|
33
|
-
- '80:80'
|
|
34
|
-
volumes:
|
|
35
|
-
- /var/run/docker.sock:/var/run/docker.sock
|
package/env.sh
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
export API_KEY=H49mG5VrVe7X9s8RJ1RhMw21W
|
|
3
|
-
export PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
|
|
4
|
-
MIIJKwIBAAKCAgEA0M45Kf922BFpP0iKeXRk3lFgQXQNBUV2+6hTxZZny+2eXs6c
|
|
5
|
-
vMPOBOhBvCAC1INsp+ytgNLfkqC+i51YBASkA2mtwH3NhPqVwj8IJh32XY4bZ7Y8
|
|
6
|
-
ZlvudFQP6CcoW6PLJEBTw6XDk9n0myvO0MfgszIjtwGTlDMTZggE5QXn9HtlGbZM
|
|
7
|
-
m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URz9OPwyDep0hos0JSSztITQC0
|
|
50
|
-
lrJLIFijFP8okb/Adw9PgsFR2/Nx8iXD8nV+OgmILs1CtSYTMF/w0Nhi8VjYZnAw
|
|
51
|
-
ls3sNONh81PzDECTz5/FBPDAZjQprKm+/VBvo1XakXMkXCZ3dwFIRy1N21RvEf04
|
|
52
|
-
dCaQxmbSZDkfkjW23A+3UCdkIUn5NupO/0WTnh6J+KUgFE4tBSx8MVyPDQwq930=
|
|
53
|
-
-----END RSA PRIVATE KEY-----"
|
|
54
|
-
export API_ENDPOINT="https://olb.bankfrick.li/webapi/v2/"
|
package/env2.sh
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
export API_KEY=pN4Fq2SPmKVyh74C68853KWjf
|
|
3
|
-
export PASSWORD=TKJ5tDz6
|
|
4
|
-
export PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
|
|
5
|
-
MIIJKQIBAAKCAgEA5YRKFCHAnTxKZ/bPor8y6vtm2O/IMS2TqlXYQsZviK3J6tEW
|
|
6
|
-
6t9RY4YkRVve+Ap2dqM7Pvco07HNQcpSOz4VzEscanEkfjHmyAry0S0OY/fjjIjr
|
|
7
|
-
whgO/0NFnJemZE9r3eePIRl7sNzkbVwE7vi8BO6R6aCviH2PpmhjAu82e5SUwj9J
|
|
8
|
-
JC/33t81iOeLgftL5oeTFmA2oz2U8NpLtcfiKoIpvsYE/ZP3Qradf3R2+O8rxdEu
|
|
9
|
-
fUbcIKAd+Q2ML3I2nZQJl0mvcb+ZwhzAlyX9faRdclm7fYlpsa0bokx5Wb1F6FWu
|
|
10
|
-
xkpq68fIAoaNyKIL2kmv2jSFSoKROjGqcss/oy3Y41x7Ny3lPf355ZUAKwNDOVAC
|
|
11
|
-
fQnC7e6tgEw0gVuS9GD1fH2QbpWW4Q0Pnl2mLYKotKt14tsUrcar9x+b73ltLhtF
|
|
12
|
-
ktSuSmMPIDXukg8K9zaLdDpkWurHke6AGexiu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est.config.js
DELETED
package/publish.sh
DELETED
|
File without changes
|
package/src/adapter.ts
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { Cache, CacheFactory } from './cache'
|
|
2
|
-
import { AdapterConfig, BaseAdapterConfig, CustomSettingsType, SettingsMap } from './config'
|
|
3
|
-
import {
|
|
4
|
-
AdapterRateLimitTier,
|
|
5
|
-
BackgroundExecuteRateLimiter,
|
|
6
|
-
FixedFrequencyRateLimiter,
|
|
7
|
-
getRateLimitingTier,
|
|
8
|
-
RequestRateLimiter,
|
|
9
|
-
SimpleCountingRateLimiter,
|
|
10
|
-
} from './rate-limiting'
|
|
11
|
-
import { Transport } from './transports'
|
|
12
|
-
import { makeLogger, SubscriptionSetFactory } from './util'
|
|
13
|
-
import { InputParameters } from './validation/input-params'
|
|
14
|
-
|
|
15
|
-
const logger = makeLogger('Adapter')
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Dependencies that will be injected into the Adapter on startup
|
|
19
|
-
*/
|
|
20
|
-
export interface AdapterDependencies {
|
|
21
|
-
// TODO: Complete docs
|
|
22
|
-
cache: Cache
|
|
23
|
-
requestRateLimiter: RequestRateLimiter
|
|
24
|
-
backgroundExecuteRateLimiter: BackgroundExecuteRateLimiter
|
|
25
|
-
subscriptionSetFactory: SubscriptionSetFactory
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Context that will be used on background executions of a Transport.
|
|
30
|
-
* For example, the endpointName used to log statements or generate Cache keys.
|
|
31
|
-
*/
|
|
32
|
-
export interface AdapterContext<
|
|
33
|
-
CustomSettings extends CustomSettingsType<CustomSettings> = SettingsMap,
|
|
34
|
-
> {
|
|
35
|
-
adapterEndpoint: AdapterEndpoint
|
|
36
|
-
adapterConfig: AdapterConfig<CustomSettings>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Structure to describe rate limits specs for the Adapter
|
|
41
|
-
*/
|
|
42
|
-
interface AdapterRateLimitingConfig {
|
|
43
|
-
/** Adapter rate limits, gotten from the specific tier requested */
|
|
44
|
-
tiers: Record<string, AdapterRateLimitTier>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Main structure of an External Adapter
|
|
49
|
-
*/
|
|
50
|
-
export interface Adapter {
|
|
51
|
-
/** Name of the adapter */
|
|
52
|
-
name: string
|
|
53
|
-
|
|
54
|
-
/** If present, the string that will be used for requests with no specified endpoint */
|
|
55
|
-
defaultEndpoint?: string
|
|
56
|
-
|
|
57
|
-
/** List of [[AdapterEndpoint]]s in the adapter */
|
|
58
|
-
endpoints: AdapterEndpoint[]
|
|
59
|
-
|
|
60
|
-
/** Map of overrides to the default config values for an Adapter */
|
|
61
|
-
envDefaultOverrides?: Partial<BaseAdapterConfig>
|
|
62
|
-
|
|
63
|
-
/** List of custom env vars for this particular adapter (e.g. RPC_URL) */
|
|
64
|
-
customSettings?: SettingsMap
|
|
65
|
-
|
|
66
|
-
/** Configuration relevant to outbound (EA --\> DP) communication rate limiting */
|
|
67
|
-
rateLimiting?: AdapterRateLimitingConfig
|
|
68
|
-
|
|
69
|
-
/** Overrides for converting the 'base' parameter that are hardcoded into the adapter. */
|
|
70
|
-
// This must be included in the middleware in order to generate deterministing cache keys for hardcoded overrides
|
|
71
|
-
overrides?: Record<string, string>
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Structure to describe rate limits specs for a specific adapter endpoint
|
|
76
|
-
*/
|
|
77
|
-
export interface EndpointRateLimitingConfig {
|
|
78
|
-
/**
|
|
79
|
-
* How much of the total limit for the adapter will be assigned to this specific endpoint.
|
|
80
|
-
* Should be a non-zero positive number up to 100.
|
|
81
|
-
* Endpoints in the same adapter without a specific allocation will divide the remaining limits equally.
|
|
82
|
-
*/
|
|
83
|
-
allocationPercentage: number
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Structure to describe a specific endpoint in an [[Adapter]]
|
|
88
|
-
*/
|
|
89
|
-
export interface AdapterEndpoint {
|
|
90
|
-
/** Name that will be used to match input params to this endpoint (case insensitive) */
|
|
91
|
-
name: string
|
|
92
|
-
|
|
93
|
-
/** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
|
|
94
|
-
aliases?: string[]
|
|
95
|
-
|
|
96
|
-
/** Transport that will be used to handle data processing and communication for this endpoint */
|
|
97
|
-
transport: Transport<any, any, any>
|
|
98
|
-
|
|
99
|
-
/** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
|
|
100
|
-
inputParameters: InputParameters
|
|
101
|
-
|
|
102
|
-
/** Specific details related to the rate limiting for this endpoint in particular */
|
|
103
|
-
rateLimiting?: EndpointRateLimitingConfig
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Structure to describe an adapter that has been initialized
|
|
108
|
-
*/
|
|
109
|
-
export interface InitializedAdapter extends Adapter {
|
|
110
|
-
/** Object containing alias translations for all endpoints */
|
|
111
|
-
endpointsMap: Record<string, AdapterEndpoint>
|
|
112
|
-
|
|
113
|
-
/** Initialized dependencies that the adapter will use */
|
|
114
|
-
dependencies: AdapterDependencies
|
|
115
|
-
|
|
116
|
-
/** Configuration params for various adapter properties */
|
|
117
|
-
config: AdapterConfig
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* This function will take an adapter structure and go through each endpoint, calculating
|
|
122
|
-
* each one's allocation of the total rate limits that are set for the adapter as a whole.
|
|
123
|
-
*
|
|
124
|
-
* @param adapter - the adapter to initialize rate limiting for
|
|
125
|
-
*/
|
|
126
|
-
const calculateRateLimitAllocations = (adapter: Adapter) => {
|
|
127
|
-
const numberOfEndpoints = adapter.endpoints.length
|
|
128
|
-
const endpointsWithExplicitAllocations = adapter.endpoints.filter((e) => e.rateLimiting)
|
|
129
|
-
|
|
130
|
-
const totalExplicitAllocation = endpointsWithExplicitAllocations
|
|
131
|
-
.map((e) => e.rateLimiting?.allocationPercentage || 0)
|
|
132
|
-
.reduce((sum, next) => sum + next, 0)
|
|
133
|
-
|
|
134
|
-
if (totalExplicitAllocation > 100) {
|
|
135
|
-
throw new Error('The total allocation set for all endpoints summed cannot exceed 100%')
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
totalExplicitAllocation === 100 &&
|
|
140
|
-
numberOfEndpoints - endpointsWithExplicitAllocations.length > 0
|
|
141
|
-
) {
|
|
142
|
-
throw new Error(
|
|
143
|
-
'The explicit allocation is at 100% but there are endpoints with implicit allocation',
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const implicitAllocation = 100 - totalExplicitAllocation
|
|
148
|
-
|
|
149
|
-
logger.debug('Adapter rate limit allocations:')
|
|
150
|
-
for (const endpoint of adapter.endpoints) {
|
|
151
|
-
if (!endpoint.rateLimiting) {
|
|
152
|
-
endpoint.rateLimiting = {
|
|
153
|
-
allocationPercentage:
|
|
154
|
-
implicitAllocation / (numberOfEndpoints - endpointsWithExplicitAllocations.length),
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
logger.debug(`Endpoint [${endpoint.name}] - ${endpoint.rateLimiting?.allocationPercentage}%`)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* This function will process dependencies for an adapter, such as caches or rate limiters,
|
|
164
|
-
* in order to inject them into transports and other relevant places later in the lifecycle.
|
|
165
|
-
*
|
|
166
|
-
* @param config - the configuration for this adapter
|
|
167
|
-
* @param inputDependencies - a partial obj of initialized dependencies to override the created ones
|
|
168
|
-
* @param rateLimitingConfig - details from the adapter regarding rate limiting
|
|
169
|
-
* @returns a set of AdapterDependencies all initialized
|
|
170
|
-
*/
|
|
171
|
-
export const initializeDependencies = (
|
|
172
|
-
adapter: Adapter,
|
|
173
|
-
config: AdapterConfig,
|
|
174
|
-
inputDependencies?: Partial<AdapterDependencies>,
|
|
175
|
-
): AdapterDependencies => {
|
|
176
|
-
const dependencies = inputDependencies || {}
|
|
177
|
-
if (!dependencies.cache) {
|
|
178
|
-
dependencies.cache = CacheFactory.buildCache(config)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// In the future we might want something more complex, but for now it's better to simplify
|
|
182
|
-
// and just use the same rate limiting for everything. Once we have a more complex use case we
|
|
183
|
-
// can think of ways to make this more configurable.
|
|
184
|
-
const rateLimitingTier = getRateLimitingTier(
|
|
185
|
-
adapter.rateLimiting?.tiers,
|
|
186
|
-
config.RATE_LIMIT_API_TIER,
|
|
187
|
-
)
|
|
188
|
-
if (!dependencies.requestRateLimiter) {
|
|
189
|
-
dependencies.requestRateLimiter = new SimpleCountingRateLimiter().initialize(
|
|
190
|
-
adapter.endpoints,
|
|
191
|
-
rateLimitingTier,
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
if (!dependencies.backgroundExecuteRateLimiter) {
|
|
195
|
-
dependencies.backgroundExecuteRateLimiter = new FixedFrequencyRateLimiter().initialize(
|
|
196
|
-
adapter.endpoints,
|
|
197
|
-
rateLimitingTier,
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
if (!dependencies.subscriptionSetFactory) {
|
|
201
|
-
dependencies.subscriptionSetFactory = new SubscriptionSetFactory(config)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return dependencies as AdapterDependencies
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
|
|
209
|
-
* i.e. makes them lowercase for now
|
|
210
|
-
* @param adapter - an instance of an Adapter
|
|
211
|
-
*/
|
|
212
|
-
const normalizeEndpointNames = (adapter: Adapter) => {
|
|
213
|
-
// Make endpoints case insensitive, including default
|
|
214
|
-
adapter.defaultEndpoint = adapter.defaultEndpoint?.toLowerCase()
|
|
215
|
-
|
|
216
|
-
for (const endpoint of adapter.endpoints) {
|
|
217
|
-
endpoint.name = endpoint.name.toLowerCase()
|
|
218
|
-
endpoint.aliases = endpoint.aliases?.map((a) => a.toLowerCase())
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
|
|
224
|
-
* Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
|
|
225
|
-
*
|
|
226
|
-
* @param adapter - an instance of an Adapter
|
|
227
|
-
* @param dependencies - dependencies that the adapter will need at initialization
|
|
228
|
-
* @param config - configuration variables already processed and validated
|
|
229
|
-
* @returns - the adapter with all transports initialized and aliases map built
|
|
230
|
-
*/
|
|
231
|
-
export const initializeAdapter = async (
|
|
232
|
-
adapter: Adapter,
|
|
233
|
-
config: AdapterConfig,
|
|
234
|
-
dependencies?: Partial<AdapterDependencies>,
|
|
235
|
-
): Promise<InitializedAdapter> => {
|
|
236
|
-
normalizeEndpointNames(adapter)
|
|
237
|
-
calculateRateLimitAllocations(adapter)
|
|
238
|
-
const initializedDependencies = initializeDependencies(adapter, config, dependencies)
|
|
239
|
-
|
|
240
|
-
const endpointsMap: Record<string, AdapterEndpoint> = {}
|
|
241
|
-
|
|
242
|
-
for (const endpoint of adapter.endpoints) {
|
|
243
|
-
// Add aliases to map to use in validation
|
|
244
|
-
const aliases = [endpoint.name, ...(endpoint.aliases || [])]
|
|
245
|
-
for (const alias of aliases) {
|
|
246
|
-
if (endpointsMap[alias]) {
|
|
247
|
-
throw new Error(`Duplicate endpoint / alias: "${alias}"`)
|
|
248
|
-
}
|
|
249
|
-
endpointsMap[alias] = endpoint
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
logger.debug(`Initializing transport for endpoint "${endpoint.name}"...`)
|
|
253
|
-
await endpoint.transport.initialize(initializedDependencies)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
logger.debug('Adapter initialization complete.')
|
|
257
|
-
return {
|
|
258
|
-
...adapter,
|
|
259
|
-
endpointsMap,
|
|
260
|
-
dependencies: initializedDependencies,
|
|
261
|
-
config,
|
|
262
|
-
}
|
|
263
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Server } from 'http'
|
|
2
|
-
import { AdapterContext, InitializedAdapter } from './adapter'
|
|
3
|
-
import { makeLogger, sleep } from './util'
|
|
4
|
-
|
|
5
|
-
const logger = makeLogger('BackgroundExecutor')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Very simple background loop that will call the [[Transport.backgroundExecute]] functions in all Transports.
|
|
9
|
-
* It gets the time in ms to wait as the return value from those functions, and sleeps until next execution.
|
|
10
|
-
*
|
|
11
|
-
* @param adapter - an initialized External Adapter
|
|
12
|
-
* @param server - the http server to attach an on close listener to
|
|
13
|
-
*/
|
|
14
|
-
export async function callBackgroundExecutes(adapter: InitializedAdapter, server?: Server) {
|
|
15
|
-
// Set up variable to check later on to see if we need to stop this background "thread"
|
|
16
|
-
// If no server is provided, the listener won't be set and serverClosed will always be false
|
|
17
|
-
let serverClosed = false
|
|
18
|
-
server?.on('close', () => {
|
|
19
|
-
serverClosed = true
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
for (const endpoint of adapter.endpoints) {
|
|
23
|
-
const backgroundExecute = endpoint.transport.backgroundExecute?.bind(endpoint.transport)
|
|
24
|
-
if (!backgroundExecute) {
|
|
25
|
-
logger.debug(`Endpoint "${endpoint.name}" has no background execute, skipping...`)
|
|
26
|
-
continue
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const context: AdapterContext = {
|
|
30
|
-
adapterEndpoint: endpoint,
|
|
31
|
-
adapterConfig: adapter.config,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const handler = async () => {
|
|
35
|
-
if (serverClosed) {
|
|
36
|
-
logger.info('Server closed, stopping recursive backgroundExecute handler chain')
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
logger.debug(`Calling background execute for endpoint "${endpoint.name}"`)
|
|
41
|
-
const timeToWait = await backgroundExecute(context)
|
|
42
|
-
logger.debug(
|
|
43
|
-
`Finished background execute for endpoint "${endpoint.name}", sleeping for ${timeToWait}ms`,
|
|
44
|
-
)
|
|
45
|
-
await sleep(timeToWait)
|
|
46
|
-
handler()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Start recursive async calls
|
|
50
|
-
handler()
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/cache/factory.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Redis from 'ioredis'
|
|
2
|
-
import { AdapterConfig } from '../config'
|
|
3
|
-
import { makeLogger } from '../util'
|
|
4
|
-
import { LocalCache } from './local'
|
|
5
|
-
import * as cacheMetrics from './metrics'
|
|
6
|
-
import { RedisCache } from './redis'
|
|
7
|
-
|
|
8
|
-
const logger = makeLogger('CacheFactory')
|
|
9
|
-
export class CacheFactory {
|
|
10
|
-
static buildCache(config: AdapterConfig) {
|
|
11
|
-
logger.info(`Using "${config.CACHE_TYPE}" cache.`)
|
|
12
|
-
if (config.CACHE_TYPE === 'local') {
|
|
13
|
-
return new LocalCache()
|
|
14
|
-
} else if (config.CACHE_TYPE === 'redis') {
|
|
15
|
-
const redis = new Redis({
|
|
16
|
-
enableAutoPipelining: true, // This will make multiple commands be batch automatically
|
|
17
|
-
host: config.CACHE_REDIS_HOST,
|
|
18
|
-
port: config.CACHE_REDIS_PORT,
|
|
19
|
-
})
|
|
20
|
-
redis.on('connect', () => {
|
|
21
|
-
cacheMetrics.redisConnectionsOpen.inc()
|
|
22
|
-
})
|
|
23
|
-
return new RedisCache(redis)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|