mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
Put topic in the config file
This commit is contained in:
parent
b1e9752986
commit
dab39a3093
|
|
@ -48,10 +48,11 @@ func main() {
|
|||
}
|
||||
|
||||
cfg := config.ClientAPI{
|
||||
ServerName: "localhost",
|
||||
KeyID: "ed25519:something",
|
||||
PrivateKey: privKey,
|
||||
KafkaProducerURIs: []string{"localhost:9092"},
|
||||
ServerName: "localhost",
|
||||
KeyID: "ed25519:something",
|
||||
PrivateKey: privKey,
|
||||
KafkaProducerURIs: []string{"localhost:9092"},
|
||||
ClientAPIOutputTopic: "clientapiOutput",
|
||||
}
|
||||
|
||||
log.Info("Starting clientapi")
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ type ClientAPI struct {
|
|||
KeyID string
|
||||
// A list of URIs to send events to. These kafka logs should be consumed by a Room Server.
|
||||
KafkaProducerURIs []string
|
||||
// The topic for events which are written to the logs.
|
||||
ClientAPIOutputTopic string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ func createRoom(req *http.Request, cfg config.ClientAPI, roomID string, producer
|
|||
}
|
||||
|
||||
// send events to the room server
|
||||
msgs, err := eventsToMessages(builtEvents)
|
||||
msgs, err := eventsToMessages(builtEvents, cfg.ClientAPIOutputTopic)
|
||||
if err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
|
|
@ -252,7 +252,7 @@ func authEventsFromStateNeeded(eventsNeeded gomatrixserverlib.StateNeeded,
|
|||
return
|
||||
}
|
||||
|
||||
func eventsToMessages(events []*gomatrixserverlib.Event) ([]*sarama.ProducerMessage, error) {
|
||||
func eventsToMessages(events []*gomatrixserverlib.Event, topic string) ([]*sarama.ProducerMessage, error) {
|
||||
msgs := make([]*sarama.ProducerMessage, len(events))
|
||||
for i, e := range events {
|
||||
var m sarama.ProducerMessage
|
||||
|
|
@ -273,7 +273,7 @@ func eventsToMessages(events []*gomatrixserverlib.Event) ([]*sarama.ProducerMess
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m.Topic = "clientapiOutput" // TODO: Make this customisable like roomserver is?
|
||||
m.Topic = topic
|
||||
m.Key = sarama.StringEncoder(e.EventID())
|
||||
m.Value = sarama.ByteEncoder(value)
|
||||
msgs[i] = &m
|
||||
|
|
|
|||
Loading…
Reference in a new issue