mirror of
https://github.com/matrix-org/dendrite
synced 2024-06-08 15:38:58 +02:00
41c6a3737e
* A kafkaesque room event consumer for the roomserver. Implement the main input loop for the roomserver. It will receive events from a kafkaesque event source and track where it is in the stream. It currently does nothing with the events it consumes.
45 lines
808 B
Go
45 lines
808 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/matrix-org/dendrite/roomserver/input"
|
|
"github.com/matrix-org/dendrite/roomserver/storage"
|
|
sarama "gopkg.in/Shopify/sarama.v1"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
database = os.Getenv("DATABASE")
|
|
kafkaURIs = strings.Split(os.Getenv("KAFKA_URIS"), ",")
|
|
roomEventTopic = os.Getenv("TOPIC_ROOM_EVENT")
|
|
)
|
|
|
|
func main() {
|
|
db, err := storage.Open(database)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
kafkaConsumer, err := sarama.NewConsumer(kafkaURIs, nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
consumer := input.Consumer{
|
|
Consumer: kafkaConsumer,
|
|
DB: db,
|
|
RoomEventTopic: roomEventTopic,
|
|
}
|
|
|
|
if err = consumer.Start(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println("Started roomserver")
|
|
|
|
// Wait forever.
|
|
// TODO: Implement clean shutdown.
|
|
select {}
|
|
}
|