aboutsummaryrefslogtreecommitdiff
path: root/syncapi
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-05-06 15:33:34 +0200
committerGitHub <noreply@github.com>2022-05-06 15:33:34 +0200
commit6493c0c0f23bb930cc8a2ce071a66b7d4b5ec9eb (patch)
treead4beb518a4f25542b0dcebe7e8efc95220c337c /syncapi
parent507f63d0fc8158f200f3e29fd36e5f09c83e62db (diff)
Move LL cache (#2429)
Diffstat (limited to 'syncapi')
-rw-r--r--syncapi/routing/context.go4
-rw-r--r--syncapi/routing/messages.go2
-rw-r--r--syncapi/routing/routing.go2
-rw-r--r--syncapi/streams/stream_pdu.go2
-rw-r--r--syncapi/streams/streams.go2
-rw-r--r--syncapi/syncapi.go8
6 files changed, 8 insertions, 12 deletions
diff --git a/syncapi/routing/context.go b/syncapi/routing/context.go
index f5f4b2dd..87cc2aae 100644
--- a/syncapi/routing/context.go
+++ b/syncapi/routing/context.go
@@ -45,7 +45,7 @@ func Context(
rsAPI roomserver.SyncRoomserverAPI,
syncDB storage.Database,
roomID, eventID string,
- lazyLoadCache *caching.LazyLoadCache,
+ lazyLoadCache caching.LazyLoadCache,
) util.JSONResponse {
filter, err := parseRoomEventFilter(req)
if err != nil {
@@ -155,7 +155,7 @@ func applyLazyLoadMembers(
filter *gomatrixserverlib.RoomEventFilter,
eventsAfter, eventsBefore []gomatrixserverlib.ClientEvent,
state []*gomatrixserverlib.HeaderedEvent,
- lazyLoadCache *caching.LazyLoadCache,
+ lazyLoadCache caching.LazyLoadCache,
) []*gomatrixserverlib.HeaderedEvent {
if filter == nil || !filter.LazyLoadMembers {
return state
diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go
index f19dfaed..b0c990ec 100644
--- a/syncapi/routing/messages.go
+++ b/syncapi/routing/messages.go
@@ -63,7 +63,7 @@ func OnIncomingMessagesRequest(
rsAPI api.SyncRoomserverAPI,
cfg *config.SyncAPI,
srp *sync.RequestPool,
- lazyLoadCache *caching.LazyLoadCache,
+ lazyLoadCache caching.LazyLoadCache,
) util.JSONResponse {
var err error
diff --git a/syncapi/routing/routing.go b/syncapi/routing/routing.go
index 245ee5b6..6bc495d8 100644
--- a/syncapi/routing/routing.go
+++ b/syncapi/routing/routing.go
@@ -39,7 +39,7 @@ func Setup(
userAPI userapi.SyncUserAPI,
rsAPI api.SyncRoomserverAPI,
cfg *config.SyncAPI,
- lazyLoadCache *caching.LazyLoadCache,
+ lazyLoadCache caching.LazyLoadCache,
) {
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go
index f774a1af..00b3dfe3 100644
--- a/syncapi/streams/stream_pdu.go
+++ b/syncapi/streams/stream_pdu.go
@@ -32,7 +32,7 @@ type PDUStreamProvider struct {
tasks chan func()
workers atomic.Int32
// userID+deviceID -> lazy loading cache
- lazyLoadCache *caching.LazyLoadCache
+ lazyLoadCache caching.LazyLoadCache
rsAPI roomserverAPI.SyncRoomserverAPI
}
diff --git a/syncapi/streams/streams.go b/syncapi/streams/streams.go
index af2a0387..1ca4ee8c 100644
--- a/syncapi/streams/streams.go
+++ b/syncapi/streams/streams.go
@@ -27,7 +27,7 @@ type Streams struct {
func NewSyncStreamProviders(
d storage.Database, userAPI userapi.SyncUserAPI,
rsAPI rsapi.SyncRoomserverAPI, keyAPI keyapi.SyncKeyAPI,
- eduCache *caching.EDUCache, lazyLoadCache *caching.LazyLoadCache, notifier *notifier.Notifier,
+ eduCache *caching.EDUCache, lazyLoadCache caching.LazyLoadCache, notifier *notifier.Notifier,
) *Streams {
streams := &Streams{
PDUStreamProvider: &PDUStreamProvider{
diff --git a/syncapi/syncapi.go b/syncapi/syncapi.go
index 686e2044..6da8ce6d 100644
--- a/syncapi/syncapi.go
+++ b/syncapi/syncapi.go
@@ -53,12 +53,8 @@ func AddPublicRoutes(
}
eduCache := caching.NewTypingCache()
- lazyLoadCache, err := caching.NewLazyLoadCache()
- if err != nil {
- logrus.WithError(err).Panicf("failed to create lazy loading cache")
- }
notifier := notifier.NewNotifier()
- streams := streams.NewSyncStreamProviders(syncDB, userAPI, rsAPI, keyAPI, eduCache, lazyLoadCache, notifier)
+ streams := streams.NewSyncStreamProviders(syncDB, userAPI, rsAPI, keyAPI, eduCache, base.Caches, notifier)
notifier.SetCurrentPosition(streams.Latest(context.Background()))
if err = notifier.Load(context.Background(), syncDB); err != nil {
logrus.WithError(err).Panicf("failed to load notifier ")
@@ -146,6 +142,6 @@ func AddPublicRoutes(
routing.Setup(
base.PublicClientAPIMux, requestPool, syncDB, userAPI,
- rsAPI, cfg, lazyLoadCache,
+ rsAPI, cfg, base.Caches,
)
}