diff --git a/src/github.com/matrix-org/dendrite/clientapi/clientapi-app/main.go b/src/github.com/matrix-org/dendrite/clientapi/clientapi-app/main.go index 82a08e767..d8be9a2b2 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/clientapi-app/main.go +++ b/src/github.com/matrix-org/dendrite/clientapi/clientapi-app/main.go @@ -17,7 +17,6 @@ package clientapi import ( "fmt" "net/http" - "net/url" "strings" "golang.org/x/crypto/ed25519" @@ -31,21 +30,17 @@ import ( ) // App is a function that configures and starts a client API server -func App(host string, kafkaURIsStr string, roomserverURL string, topicPrefix string) { - if host == "" { - log.Panic("No host specified.") +func App(address string, kafkaAddressesStr string, roomserverURL string, topicPrefix string) { + if address == "" { + log.Panic("No address specified.") } - hostURL, err := url.Parse(host) - if hostURL.Port() == "" { - host += ":7778" - } - kafkaURIs := strings.Split(kafkaURIsStr, ",") - if len(kafkaURIs) == 0 { + kafkaAddresses := strings.Split(kafkaAddressesStr, ",") + if len(kafkaAddresses) == 0 { // the kafka default is :9092 - kafkaURIs = []string{"localhost:9092"} + kafkaAddresses = []string{"localhost:9092"} } if roomserverURL == "" { - log.Panic("No roomserver host specified.") + log.Panic("No roomserver URL specified.") } clientAPIOutputTopic := fmt.Sprintf("%sroomserver_input_topic", topicPrefix) @@ -58,27 +53,27 @@ func App(host string, kafkaURIsStr string, roomserverURL string, topicPrefix str } cfg := config.ClientAPI{ - ServerName: "localhost", - KeyID: "ed25519:something", - PrivateKey: privKey, - KafkaProducerURIs: kafkaURIs, - ClientAPIOutputTopic: clientAPIOutputTopic, - RoomserverURL: roomserverURL, + ServerName: "localhost", + KeyID: "ed25519:something", + PrivateKey: privKey, + KafkaProducerAddresses: kafkaAddresses, + ClientAPIOutputTopic: clientAPIOutputTopic, + RoomserverURL: roomserverURL, } - log.Infoln("clientapi host:", host) + log.Infoln("clientapi address:", address) log.Infoln("clientapi output topic:", clientAPIOutputTopic) - log.Infoln("kafka URIs:", kafkaURIs) + log.Infoln("kafka addresses:", kafkaAddresses) log.Infoln("roomserver URL:", roomserverURL) log.Info("Starting clientapi") - roomserverProducer, err := producers.NewRoomserverProducer(cfg.KafkaProducerURIs, cfg.ClientAPIOutputTopic) + roomserverProducer, err := producers.NewRoomserverProducer(cfg.KafkaProducerAddresses, cfg.ClientAPIOutputTopic) if err != nil { - log.Panicf("Failed to setup kafka producers(%s): %s", cfg.KafkaProducerURIs, err) + log.Panicf("Failed to setup kafka producers(%s): %s", cfg.KafkaProducerAddresses, err) } queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomserverURL, nil) routing.Setup(http.DefaultServeMux, http.DefaultClient, cfg, roomserverProducer, queryAPI) - log.Fatal(http.ListenAndServe(host, nil)) + log.Fatal(http.ListenAndServe(address, nil)) } diff --git a/src/github.com/matrix-org/dendrite/clientapi/config/config.go b/src/github.com/matrix-org/dendrite/clientapi/config/config.go index 4413cb999..72e6a9b92 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/config/config.go +++ b/src/github.com/matrix-org/dendrite/clientapi/config/config.go @@ -25,8 +25,8 @@ type ClientAPI struct { // An arbitrary string used to uniquely identify the PrivateKey. Must start with the // prefix "ed25519:". KeyID string - // A list of URIs to send events to. These kafka logs should be consumed by a Room Server. - KafkaProducerURIs []string + // A list of addresses to send events to. These kafka logs should be consumed by a Room Server. + KafkaProducerAddresses []string // The topic for events which are written to the logs. ClientAPIOutputTopic string // The URL of the roomserver which can service Query API requests diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-client-api-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-client-api-server/main.go index d6d6f36b6..ce9a2a152 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-client-api-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-client-api-server/main.go @@ -62,19 +62,19 @@ func main() { } cfg := config.ClientAPI{ - ServerName: "localhost", - KeyID: "ed25519:something", - PrivateKey: privKey, - KafkaProducerURIs: kafkaURIs, - ClientAPIOutputTopic: clientAPIOutputTopic, - RoomserverURL: roomserverURL, + ServerName: "localhost", + KeyID: "ed25519:something", + PrivateKey: privKey, + KafkaProducerAddresses: kafkaURIs, + ClientAPIOutputTopic: clientAPIOutputTopic, + RoomserverURL: roomserverURL, } log.Info("Starting clientapi") - roomserverProducer, err := producers.NewRoomserverProducer(cfg.KafkaProducerURIs, cfg.ClientAPIOutputTopic) + roomserverProducer, err := producers.NewRoomserverProducer(cfg.KafkaProducerAddresses, cfg.ClientAPIOutputTopic) if err != nil { - log.Panicf("Failed to setup kafka producers(%s): %s", cfg.KafkaProducerURIs, err) + log.Panicf("Failed to setup kafka producers(%s): %s", cfg.KafkaProducerAddresses, err) } queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomserverURL, nil) diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite/main.go index 1c8e31264..97e22d4e2 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite/main.go @@ -41,16 +41,16 @@ Arguments: One of: client-api, room-server, sync-api. Options: - -c , --config-file= - Path to a YAML-format configuration file. - -H , --host= - Host to bind. The port is optional and ignored for 'serve all'. The + -a
, --address=
+ Address to bind. The port is required but ignored for 'serve all'. The default ports are: 7776 (sync-api), 7777 (room-server), and 7778 (client-api) [default: localhost] + -c , --config-file= + Path to a YAML-format configuration file. -h, --help Print this usage text. - -k , --kafka-hosts= - A comma-separated list of Kafka hosts. [default: localhost:9092] + -k , --kafka-addresses= + A comma-separated list of Kafka addresses. [default: localhost:9092] -l , --log-dir= Path to log directory. If not set, logs will only be written to stderr. -r , --room-server-host= @@ -86,9 +86,13 @@ Environment Variables: switch serverType := args[""]; serverType { case "client-api": log.Infof("Starting %v server...", serverType) + address := maybeArgToStr(args["--address"]) + if address == "localhost" { + address += ":7778" + } clientapi.App( - maybeArgToStr(args["--host"]), - maybeArgToStr(args["--kafka-hosts"]), + address, + maybeArgToStr(args["--kafka-addresses"]), maybeArgToStr(args["--room-server-host"]), maybeArgToStr(args["--topic-prefix"]), )