github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/pipeline/input.go (about) 1 // Copyright 2021 iLogtail Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package pipeline 16 17 // MetricInput ... 18 type MetricInput interface { 19 // Init called for init some system resources, like socket, mutex... 20 // return call interval(ms) and error flag, if interval is 0, use default interval 21 Init(Context) (int, error) 22 23 // Description returns a one-sentence description on the Input 24 Description() string 25 } 26 27 type MetricInputV1 interface { 28 MetricInput 29 // Collect takes in an accumulator and adds the metrics that the Input 30 // gathers. This is called every "interval" 31 Collect(Collector) error 32 } 33 34 type MetricInputV2 interface { 35 MetricInput 36 // Collect takes in an accumulator and adds the metrics that the Input 37 // gathers. This is called every "interval" 38 Read(PipelineContext) error 39 } 40 41 // ServiceInput ... 42 type ServiceInput interface { 43 // Init called for init some system resources, like socket, mutex... 44 // return interval(ms) and error flag, if interval is 0, use default interval 45 Init(Context) (int, error) 46 47 // Description returns a one-sentence description on the Input 48 Description() string 49 50 // Stop stops the services and closes any necessary channels and connections 51 Stop() error 52 } 53 54 type ServiceInputV1 interface { 55 ServiceInput 56 // Start starts the ServiceInput's service, whatever that may be 57 Start(Collector) error 58 } 59 60 type ServiceInputV2 interface { 61 ServiceInput 62 // StartService starts the ServiceInput's service, whatever that may be 63 StartService(PipelineContext) error 64 }