app

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

Documentation

Overview

Package app 提供应用程序框架。开发者只需关注组件注册

Package app 提供应用程序框架

Package app 提供应用程序框架

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   string
	BuildTime string
	GitCommit string
)

Version, BuildTime, GitCommit 由 cmd/main 设置

Functions

func LoadConfig

func LoadConfig(path string) (*dataflow.FlowConfig, error)

LoadConfig 加载 Flow 配置文件

func PrintUsage

func PrintUsage()

PrintUsage 打印使用说明

func PrintVersion

func PrintVersion()

PrintVersion 打印版本信息

func RegisterAllBuiltins

func RegisterAllBuiltins(r *dataflow.Registry[Record])

RegisterAllBuiltins 一次性注册所有内置组件

func RegisterBuiltinProcessors

func RegisterBuiltinProcessors(r *dataflow.Registry[Record])

RegisterBuiltinProcessors 注册所有内置 Processor 组件

func RegisterBuiltinSinks

func RegisterBuiltinSinks(r *dataflow.Registry[Record])

RegisterBuiltinSinks 注册所有内置 Sink 组件

func RegisterBuiltinSources

func RegisterBuiltinSources(r *dataflow.Registry[Record])

RegisterBuiltinSources 注册所有内置 Source 组件

Types

type App

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

App 数据流应用

func NewApp

func NewApp(opts Options) *App

NewApp 创建应用实例

func (*App) ListComponents

func (a *App) ListComponents()

ListComponents 列出所有已注册的组件

func (*App) Registry

func (a *App) Registry() *dataflow.Registry[Record]

Registry 返回组件注册表。用于注册自定义组件

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run 运行应用(调用前需先注册组件)

type Config

type Config struct {
	// Name 应用名称
	Name string `json:"name" yaml:"name"`
	// Log 日志配置
	Log LogConfig `json:"log" yaml:"log"`
	// Metrics 指标配置
	Metrics MetricsConfig `json:"metrics" yaml:"metrics"`
	// Parallel 是否并行运行多 Flow(可被 Flow 配置覆盖)
	// nil 表示未设置,使用默认值 true
	Parallel *bool `json:"parallel" yaml:"parallel"`
	// BufferSize 默认缓冲区大小(可被 Flow 配置覆盖)
	BufferSize int `json:"buffer_size" yaml:"buffer_size"`
}

Config 应用级全局配置

func LoadAppConfig

func LoadAppConfig(path string) (*Config, error)

LoadAppConfig 加载应用配置文件

type LogConfig

type LogConfig struct {
	// Level 日志级别: debug, info, warn, error
	Level string `json:"level" yaml:"level"`
	// Format 日志格式: text, json
	Format string `json:"format" yaml:"format"`
	// Output 输出目标: stdout, stderr, 或文件路径
	Output string `json:"output" yaml:"output"`
	// Prefix 日志前缀
	Prefix string `json:"prefix" yaml:"prefix"`
	// MaxSize 日志文件最大大小(MB),超过此大小会切割,默认 100
	MaxSize int `json:"max_size" yaml:"max_size"`
	// MaxBackups 保留的旧日志文件最大数量,默认 5
	MaxBackups int `json:"max_backups" yaml:"max_backups"`
	// MaxAge 保留旧日志文件的最大天数,默认 30
	MaxAge int `json:"max_age" yaml:"max_age"`
	// Compress 是否压缩旧日志文件,默认 false
	Compress bool `json:"compress" yaml:"compress"`
}

LogConfig 日志配置

type MetricsConfig

type MetricsConfig struct {
	// Enabled 是否启用 Prometheus 指标服务
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Addr 监听地址,默认 :9090
	Addr string `json:"addr" yaml:"addr"`
	// Path metrics 路径,默认 /metrics
	Path string `json:"path" yaml:"path"`
	// Namespace 指标命名空间,默认 dataflow
	Namespace string `json:"namespace" yaml:"namespace"`
}

MetricsConfig 指标配置

type Options

type Options struct {
	// AppConfFile 应用配置文件路径
	AppConfFile string
	// ConfigFile 单个配置文件路径
	ConfigFile string
	// ConfigDir 配置文件目录
	ConfigDir string
	// Configs 多个配置文件(逗号分隔)
	Configs string
}

Options 应用程序选项

type Record

type Record = types.Record

Record 通用数据记录类型

Jump to

Keyboard shortcuts

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