diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-14 12:01:44 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-09-14 13:01:44 -0400 |
commit | b6fb98a43176215f16fc52b64abebde51355e5c1 (patch) | |
tree | 095a2006bdfdd30d1a9c4fc4e604924fc0f50225 /store/sql_webhook_store.go | |
parent | af81f7e48bd2afaaa8c71f78bf86bdc00b104e4d (diff) | |
download | chat-b6fb98a43176215f16fc52b64abebde51355e5c1.tar.gz chat-b6fb98a43176215f16fc52b64abebde51355e5c1.tar.bz2 chat-b6fb98a43176215f16fc52b64abebde51355e5c1.zip |
remove more global references (#7442)
Diffstat (limited to 'store/sql_webhook_store.go')
-rw-r--r-- | store/sql_webhook_store.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go index 5cc2df43c..a43e78fc4 100644 --- a/store/sql_webhook_store.go +++ b/store/sql_webhook_store.go @@ -15,6 +15,7 @@ import ( type SqlWebhookStore struct { SqlStore + metrics einterfaces.MetricsInterface } const ( @@ -28,8 +29,11 @@ func ClearWebhookCaches() { webhookCache.Purge() } -func NewSqlWebhookStore(sqlStore SqlStore) WebhookStore { - s := &SqlWebhookStore{sqlStore} +func NewSqlWebhookStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) WebhookStore { + s := &SqlWebhookStore{ + SqlStore: sqlStore, + metrics: metrics, + } for _, db := range sqlStore.GetAllConns() { table := db.AddTableWithName(model.IncomingWebhook{}, "IncomingWebhooks").SetKeys(false, "Id") @@ -137,18 +141,17 @@ func (s SqlWebhookStore) GetIncoming(id string, allowFromCache bool) StoreChanne result := StoreResult{} if allowFromCache { - metrics := einterfaces.GetMetricsInterface() if cacheItem, ok := webhookCache.Get(id); ok { - if metrics != nil { - metrics.IncrementMemCacheHitCounter("Webhook") + if s.metrics != nil { + s.metrics.IncrementMemCacheHitCounter("Webhook") } result.Data = cacheItem.(*model.IncomingWebhook) storeChannel <- result close(storeChannel) return } else { - if metrics != nil { - metrics.IncrementMemCacheMissCounter("Webhook") + if s.metrics != nil { + s.metrics.IncrementMemCacheMissCounter("Webhook") } } } |