github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/pipeline/extensions/encoder.go (about) 1 // Copyright 2024 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 extensions 16 17 import ( 18 "github.com/alibaba/ilogtail/pkg/models" 19 "github.com/alibaba/ilogtail/pkg/pipeline" 20 "github.com/alibaba/ilogtail/pkg/protocol" 21 ) 22 23 // Encoder encodes data of iLogtail data models into bytes. 24 // Different drivers with different encoding protocols implement Encoder interface. 25 // 26 // drivers: raw, influxdb, prometheus, sls, ... 27 type Encoder interface { 28 EncoderV1 29 EncoderV2 30 } 31 32 // EncoderV1 supports v1 pipeline plugin interface, 33 // encodes data of v1 model into bytes. 34 // 35 // drivers: sls, influxdb, ... 36 type EncoderV1 interface { 37 EncodeV1(*protocol.LogGroup) ([][]byte, error) 38 EncodeBatchV1([]*protocol.LogGroup) ([][]byte, error) 39 } 40 41 // EncoderV2 supports v2 pipeline plugin interface, 42 // encodes data of v2 model into bytes. 43 // 44 // drivers: raw, influxdb, prometheus, ... 45 type EncoderV2 interface { 46 EncodeV2(*models.PipelineGroupEvents) ([][]byte, error) 47 EncodeBatchV2([]*models.PipelineGroupEvents) ([][]byte, error) 48 } 49 50 type EncoderExtension interface { 51 Encoder 52 pipeline.Extension 53 }