mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Move out SetCallbacks to allow for better DI
This commit is contained in:
parent
e753f51d24
commit
08f34ba5c2
@ -3,11 +3,12 @@ package handler2
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"hash/fnv"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
||||
"github.com/matrix-org/sliding-sync/internal"
|
||||
"github.com/matrix-org/sliding-sync/pubsub"
|
||||
"github.com/matrix-org/sliding-sync/state"
|
||||
@ -58,7 +59,6 @@ func NewHandler(
|
||||
}),
|
||||
typingMap: make(map[string]uint64),
|
||||
}
|
||||
pMap.SetCallbacks(h)
|
||||
|
||||
if enablePrometheus {
|
||||
h.addPrometheusMetrics()
|
||||
|
7
v3.go
7
v3.go
@ -3,12 +3,13 @@ package slidingsync
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/sliding-sync/internal"
|
||||
"github.com/matrix-org/sliding-sync/pubsub"
|
||||
@ -83,11 +84,13 @@ func Setup(destHomeserver, postgresURI, secret string, opts Opts) (*handler2.Han
|
||||
}
|
||||
pubSub := pubsub.NewPubSub(bufferSize)
|
||||
|
||||
pMap := sync2.NewPollerMap(v2Client, opts.AddPrometheusMetrics)
|
||||
// create v2 handler
|
||||
h2, err := handler2.NewHandler(postgresURI, sync2.NewPollerMap(v2Client, opts.AddPrometheusMetrics), storev2, store, v2Client, pubSub, pubSub, opts.AddPrometheusMetrics)
|
||||
h2, err := handler2.NewHandler(postgresURI, pMap, storev2, store, v2Client, pubSub, pubSub, opts.AddPrometheusMetrics)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
pMap.SetCallbacks(h2)
|
||||
|
||||
// create v3 handler
|
||||
h3, err := handler.NewSync3Handler(store, storev2, v2Client, postgresURI, secret, pubSub, pubSub, opts.AddPrometheusMetrics, opts.MaxPendingEventUpdates)
|
||||
|
Loading…
x
Reference in New Issue
Block a user