forked from
tangled.org/core
fork
Configure Feed
Select the types of activity you want to include in your feed.
Monorepo for Tangled
fork
Configure Feed
Select the types of activity you want to include in your feed.
1package config
2
3import (
4 "context"
5 "time"
6
7 "github.com/sethvargo/go-envconfig"
8)
9
10type Config struct {
11 PlcUrl string `env:"MIRROR_PLC_URL, default=https://plc.directory"`
12 TapUrl string `env:"MIRROR_TAP_URL, default=http://localhost:2480"`
13 DbUrl string `env:"MIRROR_DB_URL, required"`
14 KnotUseSSL bool `env:"MIRROR_KNOT_USE_SSL, default=false"` // use SSL for Knot when not scheme is not specified
15 KnotSSRF bool `env:"MIRROR_KNOT_SSRF, default=false"`
16 GitRepoBasePath string `env:"MIRROR_GIT_BASEPATH, default=repos"`
17 GitRepoFetchTimeout time.Duration `env:"MIRROR_GIT_FETCH_TIMEOUT, default=600s"`
18 ResyncParallelism int `env:"MIRROR_RESYNC_PARALLELISM, default=5"`
19 Slurper SlurperConfig `env:",prefix=MIRROR_SLURPER_"`
20 UseSSL bool `env:"MIRROR_USE_SSL, default=false"`
21 Hostname string `env:"MIRROR_HOSTNAME, required"`
22 Listen string `env:"MIRROR_LISTEN, default=:7000"`
23 MetricsListen string `env:"MIRROR_METRICS_LISTEN, default=127.0.0.1:7100"`
24 AdminListen string `env:"MIRROR_ADMIN_LISTEN, default=127.0.0.1:7200"`
25}
26
27func (c *Config) BaseUrl() string {
28 if c.UseSSL {
29 return "https://" + c.Hostname
30 }
31 return "http://" + c.Hostname
32}
33
34type SlurperConfig struct {
35 PersistCursorPeriod time.Duration `env:"PERSIST_CURSOR_PERIOD, default=4s"`
36 ConcurrencyPerHost int `env:"CONCURRENCY, default=4"`
37}
38
39func Load(ctx context.Context) (*Config, error) {
40 var cfg Config
41 if err := envconfig.Process(ctx, &cfg); err != nil {
42 return nil, err
43 }
44 return &cfg, nil
45}