Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEATURE]: iLogtail的extension新增encoder接口 #1660

Open
aiops1900 opened this issue Aug 7, 2024 · 0 comments
Open

[FEATURE]: iLogtail的extension新增encoder接口 #1660

aiops1900 opened this issue Aug 7, 2024 · 0 comments
Labels
feature request New feature request

Comments

@aiops1900
Copy link
Contributor

Concisely describe the proposed feature
A clear and concise description of what you want. For example,

iLogtail的 pkg/pipeline/extensions 中,已经提供了 ClientAuthenticator、Decoder 等 extension 接口,这里需要新增一个 Encoder 接口,用于各类开源协议encode driver的实现依赖(e.g. Prometheus、Influxdb等)

Describe the solution you'd like (if any)
A clear and concise description of what you want to achieve and implement. For example,

尽管现阶段各类开源协议的encode实现,都在pkg/protocol/converter中,但从软件设计看,实现不是很优雅,可以参照Decoder的思路,将encode实现也用Encoder接口做抽象统一,结合Pipeline Config灵活选择使用

Additional comments
Add any other context or screenshots about the feature request here.
For example, the ideal input and output logs.

接口形式(参考Decoder,区分SLS Log和PipelineGroupEvents模型,分别对应EncoderV1和EncoderV2)

// Encoder encodes data of iLogtail data models into bytes.
// Different drivers with different encoding protocols implement Encoder interface.
//
// drivers: raw, influxdb, prometheus, sls, ...
type Encoder interface {
	EncoderV1
	EncoderV2
}

// EncoderV1 supports v1 pipeline plugin interface,
// encodes data of v1 model into bytes.
//
// drivers: sls, influxdb, ...
type EncoderV1 interface {
	EncodeV1(*protocol.LogGroup) ([][]byte, error)
	EncodeBatchV1([]*protocol.LogGroup) ([][]byte, error)
}

// EncoderV2 supports v2 pipeline plugin interface,
// encodes data of v2 model into bytes.
//
// drivers: raw, influxdb, prometheus, ...
type EncoderV2 interface {
	EncodeV2(*models.PipelineGroupEvents) ([][]byte, error)
	EncodeBatchV2([]*models.PipelineGroupEvents) ([][]byte, error)
}

type EncoderExtension interface {
	Encoder
	pipeline.Extension
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature request New feature request
Projects
None yet
Development

No branches or pull requests

1 participant