github.com/kubewharf/katalyst-core@v0.5.3/pkg/custom-metric/store/store.go (about) 1 /* 2 Copyright 2022 The Katalyst Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Package store is the package that stores the real-time metric, 18 // katalyst may support different kinds of store implementations for 19 // different scenarios, such monolith im-memory store or distributed 20 // im-memory stores. 21 package store 22 23 import ( 24 "context" 25 26 "k8s.io/apimachinery/pkg/labels" 27 "k8s.io/apimachinery/pkg/runtime/schema" 28 29 "github.com/kubewharf/katalyst-core/pkg/custom-metric/store/data" 30 "github.com/kubewharf/katalyst-core/pkg/custom-metric/store/data/types" 31 ) 32 33 // MetricStore is a standard metric storage interface 34 type MetricStore interface { 35 Name() string 36 37 // Start and Stop are both blocked functions 38 Start() error 39 Stop() error 40 41 // InsertMetric receives metric data items, and put them into storages; 42 // this put action may not be atomic, and it's possible that some items 43 // are succeeded, while others are not; if any item is failed to be inserted, 44 // an error will be returned. 45 InsertMetric(s []*data.MetricSeries) error 46 47 // GetMetric returns the metric data items according to the given 48 // metrics references; if sharding is needed, it should be implemented 49 // as a specific MetricStore inner logic. 50 GetMetric(ctx context.Context, namespace, metricName, objName string, gr *schema.GroupResource, 51 objSelector, metricSelector labels.Selector, latest bool) ([]types.Metric, error) 52 // ListMetricMeta returns all metrics type bounded with a kubernetes objects if withObject is true 53 ListMetricMeta(ctx context.Context, withObject bool) ([]types.MetricMeta, error) 54 }