github.com/kubewharf/katalyst-core@v0.5.3/pkg/agent/resourcemanager/fetcher/plugin/plugin.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 plugin is the package that defines the reporter plugin, and 18 // those strategies must implement ReporterPlugin interface, supporting both 19 // embedded plugin and external registered plugin. 20 package plugin // import "github.com/kubewharf/katalyst-core/pkg/resourcemanager/fetcher/plugin" 21 22 import ( 23 "context" 24 25 "github.com/kubewharf/katalyst-api/pkg/protocol/reporterplugin/v1alpha1" 26 "github.com/kubewharf/katalyst-core/pkg/config" 27 "github.com/kubewharf/katalyst-core/pkg/metaserver" 28 "github.com/kubewharf/katalyst-core/pkg/metrics" 29 util "github.com/kubewharf/katalyst-core/pkg/util/process" 30 ) 31 32 const ( 33 fakePluginName = "fake-reporter-plugin" 34 ) 35 36 type InitFunc func(emitter metrics.MetricEmitter, _ *metaserver.MetaServer, conf *config.Configuration, callback ListAndWatchCallback) (ReporterPlugin, error) 37 38 // ReporterPlugin performs report actions based on system or kubelet information. 39 type ReporterPlugin interface { 40 Name() string 41 Endpoint 42 } 43 44 type DummyReporterPlugin struct { 45 *util.StopControl 46 } 47 48 func (_ DummyReporterPlugin) Name() string { return fakePluginName } 49 func (_ DummyReporterPlugin) Run(success chan<- bool) {} 50 func (_ DummyReporterPlugin) GetReportContent(c context.Context) (*v1alpha1.GetReportContentResponse, error) { 51 return nil, nil 52 } 53 54 func (_ DummyReporterPlugin) ListAndWatchReportContentCallback(s string, response *v1alpha1.GetReportContentResponse) { 55 } 56 57 func (_ DummyReporterPlugin) GetCache() *v1alpha1.GetReportContentResponse { 58 return nil 59 } 60 61 var _ ReporterPlugin = DummyReporterPlugin{}