-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfig.ts
More file actions
94 lines (76 loc) · 3.11 KB
/
Copy pathConfig.ts
File metadata and controls
94 lines (76 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export type Config = {
region: 'us-east-1', //dummy but required
/** self-hosted deployment */
dockerHost: string
buildPlatform?: string // e.g. 'linux/amd64' for remote x86 servers
dbPassword: string
minioPassword: string
/** optional Backblaze B2 off-site backup for pg dumps. all three required to enable */
b2?: {
keyId: string
appKey: string
bucket: string
}
/** optional pagerduty integration */
pagerduty_key?: string
/** optional slack channel notifications */
slack_webhook?: string
slack_positive?: string
slack_probe?: string
slack_public?: string
slack_reported_ids?: string
/** per-addon external config, passed as env vars to cron containers */
externalConfig?: { [addonName: string]: Record<string, string> }
/** options for general endpoints */
host_url?: string //defaults to https://arweave.net
gql_url?: string //defaults to https://arweave.net/graphql
gql_url_secondary?: string //defaults to https://arweave-search.goldsky.com/graphql
/** addons to load. foldername must be installed in ./addons/ */
addons: Array<string>
/** classifiers and order for linking (names must match `addons` and folder names) */
classifiers: Array<string>
// // ## whitelist IPs for http://webserver/blacklist.txt
txids_whitelist: Array<string>
/* ranges whitelist ips for nodes */
http_api_nodes_url?: string //future feature: auto update range lists
ranges_whitelist: Array<{ name: string, server: string }>
/* arweave nodes for http api retrieval (fallback host_url).
* N.B. `name` must be a FQDN (hostname) */
http_api_nodes: Array<{ name: string, server: string }>
/* ingress nodes for additional chunk streaming */
ingress_nodes: Array<{ url: string, name: string }>
/* gateways to check for blocked data */
gw_domains?: Array<string>
/** disable core services */
services: {
indexer: boolean
httpApi: boolean
webserver: boolean
checks: boolean
}
}
/** Docker resource naming convention: `{name}-shep-{stackName}` */
export const naming = (stackName: string, s: string) => `${s}-shep-${stackName}`
/** return the name of the output queue for a given classifier. important to centralize this logic for refactoring later */
export const classifierQueueName = (config: Config, i: number) => ({
queueName: `shepherd2-output-${i + 1}-${config.classifiers[i]}-q`,
dlqName: `shepherd2-output-${i + 1}-${config.classifiers[i]}-dlq`,
})
/** determine the i/o queues for a classifier */
export const ioQueueNames = (config: Config, name: string) => {
const index = config.classifiers.indexOf(name)
if (index === -1) throw new Error(`Classifier '${name}' not found`)
if (index === 0) return {
input: 'shepherd2-input-q', //this is defined in infra/stack.ts
output: classifierQueueName(config, index).queueName,
}
return {
input: classifierQueueName(config, index - 1).queueName,
output: classifierQueueName(config, index).queueName,
}
}
/** last output Q is for http-api input (n.b. may be no classifiers) */
export const finalQueueName = (config: Config): string | undefined =>
(config.classifiers.length > 0)
? classifierQueueName(config, config.classifiers.length - 1).queueName
: undefined