Add support for discovering new PDSs from relays
This commit is contained in:
parent
c919050833
commit
1abe505ef9
3 changed files with 192 additions and 0 deletions
|
@ -35,6 +35,7 @@ type Config struct {
|
|||
LogLevel int64 `default:"1"`
|
||||
MetricsPort string `split_words:"true"`
|
||||
DBUrl string `envconfig:"POSTGRES_URL"`
|
||||
Relays string
|
||||
}
|
||||
|
||||
var config Config
|
||||
|
@ -54,6 +55,16 @@ func runMain(ctx context.Context) error {
|
|||
}
|
||||
log.Debug().Msgf("DB connection established")
|
||||
|
||||
if config.Relays != "" {
|
||||
for _, host := range strings.Split(config.Relays, ",") {
|
||||
c, err := NewRelayConsumer(ctx, host, db)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("Failed to create relay consumer for %q: %s", host, err)
|
||||
}
|
||||
c.Start(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
consumersCh := make(chan struct{})
|
||||
go runConsumers(ctx, db, consumersCh)
|
||||
|
||||
|
@ -160,6 +171,7 @@ func main() {
|
|||
flag.StringVar(&config.LogFile, "log", "", "Path to the log file. If empty, will log to stderr")
|
||||
flag.StringVar(&config.LogFormat, "log-format", "text", "Logging format. 'text' or 'json'")
|
||||
flag.Int64Var(&config.LogLevel, "log-level", 1, "Log level. -1 - trace, 0 - debug, 1 - info, 5 - panic")
|
||||
flag.StringVar(&config.Relays, "relays", "", "List of relays to connect to (for discovering new PDSs)")
|
||||
|
||||
if err := envconfig.Process("consumer", &config); err != nil {
|
||||
log.Fatalf("envconfig.Process: %s", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue