source

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: 8 Imported by: 0

Documentation

Overview

Package source 提供 Python 脚本 Source 实现。 通过子进程启动 Python 脚本,从 stdout 读取 JSON lines 作为数据源。

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 Source 的配置。

type Source

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

Source 通过 Python 脚本读取数据的 Source。 Python 脚本向 stdout 输出 JSON lines,每行一个 Record。 脚本退出即表示数据结束。

func New

func New() *Source

New 创建 Source 实例。

func (*Source) Close

func (s *Source) Close() error

Close 关闭 Python 进程。

func (*Source) Init

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

Init 解析配置。

func (*Source) Read

func (s *Source) Read(ctx context.Context, out chan<- types.Record) (int64, error)

Read 从 Python 脚本 stdout 读取数据并发送到输出通道。

Jump to

Keyboard shortcuts

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