From cb5081b33200835e6486241dfdcf27eb31c4e484 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Thu, 20 Apr 2017 17:15:34 +0100 Subject: [PATCH] Yank out clientapi config options to env vars for now (#77) --- .../dendrite/cmd/dendrite-clientapi/main.go | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-clientapi/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-clientapi/main.go index 70df0a2d1..e97bd9ad4 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-clientapi/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-clientapi/main.go @@ -4,6 +4,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "golang.org/x/crypto/ed25519" @@ -31,15 +32,31 @@ func setupLogging(logDir string) { )) } +var ( + kafkaURIs = strings.Split(os.Getenv("KAFKA_URIS"), ",") + bindAddr = os.Getenv("BIND_ADDRESS") + logDir = os.Getenv("LOG_DIR") + roomserverURL = os.Getenv("ROOMSERVER_URL") + clientAPIOutputTopic = os.Getenv("CLIENTAPI_OUTPUT_TOPIC") +) + func main() { - bindAddr := os.Getenv("BIND_ADDRESS") if bindAddr == "" { log.Panic("No BIND_ADDRESS environment variable found.") } - logDir := os.Getenv("LOG_DIR") if logDir != "" { setupLogging(logDir) } + if len(kafkaURIs) == 0 { + // the kafka default is :9092 + kafkaURIs = []string{"localhost:9092"} + } + if roomserverURL == "" { + log.Panic("No ROOMSERVER_URL environment variable found.") + } + if clientAPIOutputTopic == "" { + log.Panic("No CLIENTAPI_OUTPUT_TOPIC environment variable found. This should match the roomserver input topic.") + } // TODO: Rather than generating a new key on every startup, we should be // reading a PEM formatted file instead. @@ -52,9 +69,9 @@ func main() { ServerName: "localhost", KeyID: "ed25519:something", PrivateKey: privKey, - KafkaProducerURIs: []string{"localhost:9092"}, - ClientAPIOutputTopic: "roomserverInput", - RoomserverURL: "http://localhost:7777", + KafkaProducerURIs: kafkaURIs, + ClientAPIOutputTopic: clientAPIOutputTopic, + RoomserverURL: roomserverURL, } log.Info("Starting clientapi")