json

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

Documentation

Overview

Package json 提供写入 JSON 文件的 Sink

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// FilePath 输出文件路径
	FilePath string `json:"file_path"`
	// Format 格式: "lines" 或 "array"
	Format string `json:"format"`
	// Indent 缩进字符串
	Indent string `json:"indent"`
	// Append 是否追加模式
	Append bool `json:"append"`
}

Config Sink 的配置

type Sink

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

Sink 将数据写入 JSON 文件,支持 JSON Lines 和 JSON 数组格式

func New

func New() *Sink

New 创建新的 Sink

func (*Sink) Close

func (s *Sink) Close() error

Close 关闭 Sink

func (*Sink) Consume

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

Consume 消费数据并写入 JSON 文件

func (*Sink) Count

func (s *Sink) Count() int

Count 返回已写入的记录数

func (*Sink) Init

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

Init 初始化 Sink

type WriterSink

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

WriterSink 通用的 JSON Writer Sink

func NewWriterSink

func NewWriterSink(writer io.Writer) *WriterSink

NewWriterSink 创建新的 WriterSink

func (*WriterSink) Consume

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

Consume 消费数据

func (*WriterSink) Count

func (s *WriterSink) Count() int

Count 返回已写入的记录数

func (*WriterSink) Init

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

Init 初始化 Sink

Jump to

Keyboard shortcuts

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