This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
167 lines (148 loc) · 5.25 KB
/
config.go
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package main
import (
"github.com/jawher/mow.cli"
)
type serviceConfig struct {
appSystemCode *string
appName *string
appPort *string
unfoldingWhitelist *[]string
writerURI *string
writerHealthURI *string
contentResolverURI *string
contentResolverHealthURI *string
relationsResolverURI *string
relationsResolverHealthURI *string
writeTopic *string
kafkaAddr *string
kafkaHostname *string
kafkaAuth *string
requestTimeout *int
}
func createServiceConfiguration(app *cli.Cli) *serviceConfig {
appSystemCode := app.String(cli.StringOpt{
Name: "app-system-code",
Value: "content-collection-unfolder",
Desc: "System Code of the application",
EnvVar: "APP_SYSTEM_CODE",
})
appName := app.String(cli.StringOpt{
Name: "app-name",
Value: "Content Collection Unfolder",
Desc: "Application name",
EnvVar: "APP_NAME",
})
appPort := app.String(cli.StringOpt{
Name: "app-port",
Value: "8080",
Desc: "Port to listen on",
EnvVar: "APP_PORT",
})
unfoldingWhitelist := app.Strings(cli.StringsOpt{
Name: "unfolding-whitelist",
Value: []string{"content-package"},
Desc: "Collection types for which the unfolding process should be performed",
EnvVar: "UNFOLDING_WHITELIST",
})
writerURI := app.String(cli.StringOpt{
Name: "writer-uri",
Value: "http://localhost:8080/__content-collection-rw-neo4j/content-collection/",
Desc: "URI of the Writer",
EnvVar: "WRITER_URI",
})
writerHealthURI := app.String(cli.StringOpt{
Name: "writer-health-uri",
Value: "http://localhost:8080/__content-collection-rw-neo4j/__health",
Desc: "URI of the Writer health endpoint",
EnvVar: "WRITER_HEALTH_URI",
})
contentResolverURI := app.String(cli.StringOpt{
Name: "content-resolver-uri",
Value: "http://localhost:8080/__document-store-api/content/",
Desc: "URI of the Content Resolver",
EnvVar: "CONTENT_RESOLVER_URI",
})
contentResolverHealthURI := app.String(cli.StringOpt{
Name: "content-resolver-health-uri",
Value: "http://localhost:8080/__document-store-api/__health",
Desc: "URI of the Content Resolver health endpoint",
EnvVar: "CONTENT_RESOLVER_HEALTH_URI",
})
relationsResolverURI := app.String(cli.StringOpt{
Name: "relations-resolver-uri",
Value: "http://localhost:8080/__relations-api/contentcollection/{uuid}/relations",
Desc: "URI of the relations resolver endpoint",
EnvVar: "RELATIONS_RESOLVER_URI",
})
relationsResolverHealthURI := app.String(cli.StringOpt{
Name: "relations-resolver-health-uri",
Value: "http://localhost:8080/__relations-api/__health",
Desc: "URI of the relations resolver health endpoint",
EnvVar: "RELATIONS_RESOLVER_HEALTH_URI",
})
writeTopic := app.String(cli.StringOpt{
Name: "kafka-write-topic",
Value: "PostPublicationEvents",
Desc: "The topic to write the messages to",
EnvVar: "Q_WRITE_TOPIC",
})
kafkaAddr := app.String(cli.StringOpt{
Name: "kafka-proxy-address",
Value: "http://localhost:8080",
Desc: "Addresses of the kafka proxy",
EnvVar: "Q_ADDR",
})
kafkaHostname := app.String(cli.StringOpt{
Name: "kafka-proxy-hostname",
Value: "kafka",
Desc: "The hostname of the kafka proxy (for hostname based routing)",
EnvVar: "Q_HOSTNAME",
})
kafkaAuth := app.String(cli.StringOpt{
Name: "kafka-authorization",
Desc: "Authorization for kafka",
EnvVar: "Q_AUTHORIZATION",
})
requestTimeout := app.Int(cli.IntOpt{
Name: "request_timeout",
Value: 2,
Desc: "timeout per request for taking contents from document store",
EnvVar: "REQUEST_TIMEOUT",
})
return &serviceConfig{
appSystemCode: appSystemCode,
appName: appName,
appPort: appPort,
unfoldingWhitelist: unfoldingWhitelist,
writerURI: writerURI,
writerHealthURI: writerHealthURI,
contentResolverURI: contentResolverURI,
contentResolverHealthURI: contentResolverHealthURI,
relationsResolverURI: relationsResolverURI,
relationsResolverHealthURI: relationsResolverHealthURI,
writeTopic: writeTopic,
kafkaAddr: kafkaAddr,
kafkaHostname: kafkaHostname,
kafkaAuth: kafkaAuth,
requestTimeout: requestTimeout,
}
}
func (sc *serviceConfig) toMap() map[string]interface{} {
return map[string]interface{}{
"appSystemCode": *sc.appSystemCode,
"appName": *sc.appName,
"appPort": *sc.appPort,
"unfoldingWhitelist": *sc.unfoldingWhitelist,
"writerURI": *sc.writerURI,
"writerHealthURI": *sc.writerHealthURI,
"contentResolverURI": *sc.contentResolverURI,
"contentResolverHealthURI": *sc.contentResolverHealthURI,
"relationsResolverURI": *sc.relationsResolverURI,
"relationsResolverHealthURI": *sc.relationsResolverHealthURI,
"writeTopic": *sc.writeTopic,
"kafkaAddr": *sc.kafkaAddr,
"kafkaHostname": *sc.kafkaHostname,
"kafkaAuth": *sc.kafkaAuth,
"requestTimeout": *sc.requestTimeout,
}
}