-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (31 loc) · 857 Bytes
/
main.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
package main
import (
"fmt"
"github.com/caarlos0/env/v6"
)
var (
exampleSchemaDef = "[{\"name\":\"payload\",\"type\":\"string\"},{\"name\":\"addresses\",\"type\":\"array\",\"items\":{\"type\": \"string\"} }]"
httpPort = 8000
prometheusPort = 9500
batchSize = 20
)
type Config struct {
IsWorker bool `env:"IS_WORKER" envDefault:"true"`
Url string `env:"PULSAR_URL"`
ChannelName string `env:"CHANNEL_NAME" envDefault:"webhooks"`
PrometheusPort int `env:"PROMETHEUS_PORT" envDefault:"9500"`
HttpPort int `env:"HTTP_PORT" envDefault:"8000"`
}
func main() {
cfg := Config{}
if err := env.Parse(&cfg); err != nil {
fmt.Printf("Missing context, %+v\n", err)
}
httpPort = cfg.HttpPort
prometheusPort = cfg.PrometheusPort
if cfg.IsWorker {
RunWorker(cfg)
} else {
RunGateway(cfg)
}
}