MM-21357: Use typed constants ClusterEvent (#17920)
* MM-21357: Use typed constants ClusterEvent Use typed constants for: - model.ClusterEvent https://mattermost.atlassian.net/browse/MM-21357 ```release-note Use typed constant for model.ClusterEvent ``` * trigger CI ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
9ae45d55d9
Коммит
623f8dc9af
4
services/cache/cache.go
поставляемый
4
services/cache/cache.go
поставляемый
@@ -6,6 +6,8 @@ package cache
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
// ErrKeyNotFound is the error when the given key is not found
|
||||
@@ -42,7 +44,7 @@ type Cache interface {
|
||||
Len() (int, error)
|
||||
|
||||
// GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
|
||||
GetInvalidateClusterEvent() string
|
||||
GetInvalidateClusterEvent() model.ClusterEvent
|
||||
|
||||
// Name returns the name of the cache
|
||||
Name() string
|
||||
|
||||
6
services/cache/lru.go
поставляемый
6
services/cache/lru.go
поставляемый
@@ -24,7 +24,7 @@ type LRU struct {
|
||||
items map[string]*list.Element
|
||||
defaultExpiry time.Duration
|
||||
name string
|
||||
invalidateClusterEvent string
|
||||
invalidateClusterEvent model.ClusterEvent
|
||||
}
|
||||
|
||||
// LRUOptions contains options for initializing LRU cache
|
||||
@@ -32,7 +32,7 @@ type LRUOptions struct {
|
||||
Name string
|
||||
Size int
|
||||
DefaultExpiry time.Duration
|
||||
InvalidateClusterEvent string
|
||||
InvalidateClusterEvent model.ClusterEvent
|
||||
// StripedBuckets is used only by LRUStriped and shouldn't be greater than the number
|
||||
// of CPUs available on the machine running this cache.
|
||||
StripedBuckets int
|
||||
@@ -128,7 +128,7 @@ func (l *LRU) Len() (int, error) {
|
||||
}
|
||||
|
||||
// GetInvalidateClusterEvent returns the cluster event configured when this cache was created.
|
||||
func (l *LRU) GetInvalidateClusterEvent() string {
|
||||
func (l *LRU) GetInvalidateClusterEvent() model.ClusterEvent {
|
||||
return l.invalidateClusterEvent
|
||||
}
|
||||
|
||||
|
||||
6
services/cache/lru_striped.go
поставляемый
6
services/cache/lru_striped.go
поставляемый
@@ -9,6 +9,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cespare/xxhash/v2"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
// LRUStriped keeps LRU caches in buckets in order to lower mutex contention.
|
||||
@@ -39,7 +41,7 @@ import (
|
||||
type LRUStriped struct {
|
||||
buckets []*LRU
|
||||
name string
|
||||
invalidateClusterEvent string
|
||||
invalidateClusterEvent model.ClusterEvent
|
||||
}
|
||||
|
||||
func (L LRUStriped) hashkeyMapHash(key string) uint64 {
|
||||
@@ -108,7 +110,7 @@ func (L LRUStriped) Len() (int, error) {
|
||||
}
|
||||
|
||||
// GetInvalidateClusterEvent does the same as LRU.GetInvalidateClusterEvent
|
||||
func (L LRUStriped) GetInvalidateClusterEvent() string {
|
||||
func (L LRUStriped) GetInvalidateClusterEvent() model.ClusterEvent {
|
||||
return L.invalidateClusterEvent
|
||||
}
|
||||
|
||||
|
||||
4
services/cache/provider.go
поставляемый
4
services/cache/provider.go
поставляемый
@@ -5,6 +5,8 @@ package cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
// CacheOptions contains options for initializaing a cache
|
||||
@@ -12,7 +14,7 @@ type CacheOptions struct {
|
||||
Size int
|
||||
DefaultExpiry time.Duration
|
||||
Name string
|
||||
InvalidateClusterEvent string
|
||||
InvalidateClusterEvent model.ClusterEvent
|
||||
Striped bool
|
||||
StripedBuckets int
|
||||
}
|
||||
|
||||
5
services/cache/provider_test.go
поставляемый
5
services/cache/provider_test.go
поставляемый
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -56,7 +57,7 @@ func TestNewCache(t *testing.T) {
|
||||
|
||||
size := 1
|
||||
expiry := 1 * time.Second
|
||||
event := "clusterEvent"
|
||||
event := model.ClusterEvent("clusterEvent")
|
||||
c, err := p.NewCache(&CacheOptions{
|
||||
Size: size,
|
||||
Name: "name",
|
||||
@@ -139,7 +140,7 @@ func TestNewCache_Striped(t *testing.T) {
|
||||
|
||||
size := 1
|
||||
expiry := 1 * time.Second
|
||||
event := "clusterEvent"
|
||||
event := model.ClusterEvent("clusterEvent")
|
||||
c, err := p.NewCache(&CacheOptions{
|
||||
Size: size,
|
||||
Name: "name",
|
||||
|
||||
Ссылка в новой задаче
Block a user