Skip to content

Commit

Permalink
Allow witnesses to be configured at runtime
Browse files Browse the repository at this point in the history
The witnesses that a distributor accepts should not be statically compiled into the code as we don't have a strong opinion on this set. The logs could also be made configurable at runtime in the future, but for now keeping these the same as the omniwitness makes configuration simpler and doesn't alienate any users.
  • Loading branch information
mhutchinson committed Jun 6, 2023
1 parent a388c04 commit d1d1f67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions distributor/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"database/sql"
"flag"
"io/ioutil"
"net"
"net/http"

Expand All @@ -42,19 +43,21 @@ var (
addr = flag.String("listen", ":8080", "Address to listen on")
mysqlURI = flag.String("mysql_uri", "", "URI for MySQL DB")

witnessConfigFile = flag.String("witness_config_file", "", "Path to a file containing the public keys of allowed witnesses")

// configLogs is the config for the logs this distributor will accept.
//go:embed logs.yaml
configLogs []byte

// configWitnesses is the config for the witnesses this distributor will accept.
//go:embed witnesses.yaml
configWitnesses []byte
)

func main() {
flag.Parse()
ctx := context.Background()

configWitnesses, err := ioutil.ReadFile(*witnessConfigFile)
if err != nil {
glog.Exitf("Failed to read witness_config_file (%q): %v", *witnessConfigFile, err)
}
// This error group will be used to run all top level processes.
// If any process dies, then all of them will be stopped via context cancellation.
g, ctx := errgroup.WithContext(ctx)
Expand Down
5 changes: 4 additions & 1 deletion distributor/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ services:
"--alsologtostderr",
"--v=2",
"--mysql_uri=distributor:letmein@tcp(db:3306)/distributor",
"--listen=:8080"
"--witness_config_file=/var/config/witnesses.yaml",
"--listen=:8081"
]
ports:
- "8080:8080"
restart: always
depends_on:
db:
condition: service_healthy
volumes:
- ./witnesses.yaml:/var/config/witnesses.yaml

0 comments on commit d1d1f67

Please sign in to comment.