summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-21 04:13:34 -0500
committerGeorge Goldberg <george@gberg.me>2017-09-21 10:13:34 +0100
commit266ff8670244da288aec937320d9eecc7996af35 (patch)
tree39e4e528cda0abb24be317683516ee246717fc68 /store
parentadab1a660fdc0c307238279edc7a9918d14577e5 (diff)
downloadchat-266ff8670244da288aec937320d9eecc7996af35.tar.gz
chat-266ff8670244da288aec937320d9eecc7996af35.tar.bz2
chat-266ff8670244da288aec937320d9eecc7996af35.zip
remove more global refs (#7480)
Diffstat (limited to 'store')
-rw-r--r--store/layered_store.go6
-rw-r--r--store/local_cache_supplier.go10
-rw-r--r--store/sql_store_test.go2
3 files changed, 7 insertions, 11 deletions
diff --git a/store/layered_store.go b/store/layered_store.go
index 0c6a01125..64107288c 100644
--- a/store/layered_store.go
+++ b/store/layered_store.go
@@ -24,11 +24,11 @@ type LayeredStore struct {
LayerChainHead LayeredStoreSupplier
}
-func NewLayeredStore() Store {
+func NewLayeredStore(metrics einterfaces.MetricsInterface, cluster einterfaces.ClusterInterface) Store {
store := &LayeredStore{
TmpContext: context.TODO(),
- DatabaseLayer: NewSqlSupplier(einterfaces.GetMetricsInterface()),
- LocalCacheLayer: NewLocalCacheSupplier(einterfaces.GetMetricsInterface(), einterfaces.GetClusterInterface()),
+ DatabaseLayer: NewSqlSupplier(metrics),
+ LocalCacheLayer: NewLocalCacheSupplier(metrics, cluster),
}
store.ReactionStore = &LayeredReactionStore{store}
diff --git a/store/local_cache_supplier.go b/store/local_cache_supplier.go
index 91aa94768..3627c5b39 100644
--- a/store/local_cache_supplier.go
+++ b/store/local_cache_supplier.go
@@ -32,15 +32,11 @@ func NewLocalCacheSupplier(metrics einterfaces.MetricsInterface, cluster einterf
cluster: cluster,
}
- registerClusterHandlers(supplier)
-
- return supplier
-}
-
-func registerClusterHandlers(supplier *LocalCacheSupplier) {
- if cluster := einterfaces.GetClusterInterface(); cluster != nil {
+ if cluster != nil {
cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_REACTIONS, supplier.handleClusterInvalidateReaction)
}
+
+ return supplier
}
func (s *LocalCacheSupplier) SetChainNext(next LayeredStoreSupplier) {
diff --git a/store/sql_store_test.go b/store/sql_store_test.go
index ac77357c4..4be3352e9 100644
--- a/store/sql_store_test.go
+++ b/store/sql_store_test.go
@@ -12,7 +12,7 @@ func Setup() {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
- store = NewLayeredStore()
+ store = NewLayeredStore(nil, nil)
store.MarkSystemRanUnitTests()
}