sink

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sink 提供 Python 脚本 Sink 实现。 通过子进程启动 Python 脚本,将数据通过 stdin 以 JSON lines 格式发送给 Python 处理。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Script Python 脚本路径(必填)
	Script string `json:"script"`
	// PythonExec Python 可执行文件路径,默认 "python3"
	PythonExec string `json:"python_exec"`
	// Args 传递给脚本的额外命令行参数
	Args []string `json:"args"`
	// Env 额外的环境变量(值支持 string/number/bool,自动转为字符串)
	Env map[string]interface{} `json:"env"`
}

Config Sink 的配置。

type Sink

type Sink struct {
	// contains filtered or unexported fields
}

Sink 通过 Python 脚本写入数据的 Sink。 从 Go channel 读取 Record,序列化为 JSON lines 后写入 Python 的 stdin。 当 channel 关闭后关闭 Python 的 stdin,等待 Python 处理完毕并退出。

func New

func New() *Sink

New 创建 Sink 实例。

func (*Sink) Close

func (s *Sink) Close() error

Close 关闭 Python 进程。

func (*Sink) Consume

func (s *Sink) Consume(ctx context.Context, in <-chan types.Record) error

Consume 从输入通道读取数据,通过 stdin 发送给 Python 脚本处理。

func (*Sink) Init

func (s *Sink) Init(config []byte) error

Init 解析配置。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL