/
githubmirror
/
grafana
Обзор
Документация
Войти
/
githubmirror
/
grafana
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
pkg/services/pluginsintegration/angularpatternsstore/store.go
59 строк
2 KB
Giuseppe Guerra
Plugins: Angular patterns: Use ETag for GCOM requests (#74453)
12 сен 2023, 19:03
Не верифицирован
12 сен 2023, 19:03
e9a1259
Код
Авторство
О чём код?
package angularpatternsstore import ( "context" "time" "github.com/grafana/grafana/pkg/infra/kvstore" "github.com/grafana/grafana/pkg/services/pluginsintegration/cachekvstore" ) type Service interface { GetLastUpdated(ctx context.Context) (time.Time, error) Get(ctx context.Context) (string, bool, error) Set(ctx context.Context, value any) error SetLastUpdated(ctx context.Context) error GetETag(ctx context.Context) (string, bool, error) SetETag(ctx context.Context, etag string) error } const ( kvNamespace = "plugin.angularpatterns" keyPatterns = "angular_patterns" keyEtag = "etag" ) // KVStoreService allows to cache GCOM angular patterns into the database, as a cache. type KVStoreService struct { *cachekvstore.CacheKvStore } var _ Service = (*KVStoreService)(nil) func ProvideService(kv kvstore.KVStore) Service { return &KVStoreService{ CacheKvStore: cachekvstore.NewCacheKvStore(kv, kvNamespace), } } // Get returns the stored angular patterns from the underlying cachekvstore. func (s *KVStoreService) Get(ctx context.Context) (string, bool, error) { return s.CacheKvStore.Get(ctx, keyPatterns) } // GetETag returns the stored etag from the underlying cachekvstore. func (s *KVStoreService) GetETag(ctx context.Context) (string, bool, error) { return s.CacheKvStore.Get(ctx, keyEtag) } // Set stores the given angular patterns in the underlying cachekvstore. func (s *KVStoreService) Set(ctx context.Context, value any) error { return s.CacheKvStore.Set(ctx, keyPatterns, value) } // SetETag stores the given etag in the underlying cachekvstore. func (s *KVStoreService) SetETag(ctx context.Context, etag string) error { return s.CacheKvStore.Set(ctx, keyEtag, etag) }