config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Kind       string         `json:"kind" yaml:"kind"`
	Enabled    bool           `json:"enabled" yaml:"enabled"`
	TTL        time.Duration  `json:"ttl" yaml:"ttl"`
	BaseDir    string         `json:"base_dir" yaml:"base_dir"`
	MaxSizeMB  int            `json:"max_size_mb" yaml:"max_size_mb"`
	Additional map[string]any `json:"additional" yaml:"additional"`
}

CacheConfig defines the behaviour of response caching.

func (CacheConfig) Validate

func (c CacheConfig) Validate() error

Validate ensures cache configuration is consistent.

type DiffConfig

type DiffConfig struct {
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Baseline string `json:"baseline" yaml:"baseline"`
	Preview  int    `json:"preview" yaml:"preview"`
}

DiffConfig 控制 diff/fuzzy 相关开关。

func (DiffConfig) Validate

func (c DiffConfig) Validate() error

type LimitConfig

type LimitConfig struct {
	MaxPages       int `json:"max_pages" yaml:"max_pages"`
	MaxFiles       int `json:"max_files" yaml:"max_files"`
	MaxPerFilePage int `json:"max_per_file_page" yaml:"max_per_file_page"`
}

LimitConfig handles rate and budget limits.

func (LimitConfig) Validate

func (c LimitConfig) Validate() error

Validate ensures limit values are consistent.

type PipelineConfig

type PipelineConfig struct {
	Provider ProviderConfig `json:"provider" yaml:"provider"`
	Splitter SplitterConfig `json:"splitter" yaml:"splitter"`
	Cache    CacheConfig    `json:"cache" yaml:"cache"`
	Worker   WorkerConfig   `json:"worker" yaml:"worker"`
	Limits   LimitConfig    `json:"limits" yaml:"limits"`
	Retry    RetryConfig    `json:"retry" yaml:"retry"`
	Diff     DiffConfig     `json:"diff" yaml:"diff"`
}

PipelineConfig bundles all knobs for a single OCR pipeline.

func (PipelineConfig) Validate

func (c PipelineConfig) Validate() error

Validate ensures all nested configuration segments are valid.

type ProviderConfig

type ProviderConfig struct {
	Kind       string            `json:"kind" yaml:"kind"`
	BaseURL    string            `json:"base_url" yaml:"base_url"`
	Auth       map[string]string `json:"auth" yaml:"auth"`
	Timeout    time.Duration     `json:"timeout" yaml:"timeout"`
	Headers    map[string]string `json:"headers" yaml:"headers"`
	Additional map[string]any    `json:"additional" yaml:"additional"`
}

ProviderConfig contains fields specific to the remote service.

func (ProviderConfig) Validate

func (c ProviderConfig) Validate() error

Validate ensures provider configuration is consistent.

type RetryConfig

type RetryConfig struct {
	MaxAttempts int           `json:"max_attempts" yaml:"max_attempts"`
	Backoff     time.Duration `json:"backoff" yaml:"backoff"`
	MaxBackoff  time.Duration `json:"max_backoff" yaml:"max_backoff"`
}

RetryConfig defines retry policies for provider calls.

func (RetryConfig) Validate

func (c RetryConfig) Validate() error

Validate ensures retry durations are consistent.

type ServiceConfig

type ServiceConfig struct {
	Pipelines map[string]PipelineConfig `json:"pipelines" yaml:"pipelines"`
}

ServiceConfig is the top-level configuration structure for the OCRX service.

func DefaultTextInConfig

func DefaultTextInConfig(appID, secret string) (ServiceConfig, error)

DefaultTextInConfig 根据提供的鉴权信息构造三条 TextIn 管线的默认配置。

func Load

func Load(path string) (ServiceConfig, error)

Load 从 YAML 文件加载 ServiceConfig。

func (ServiceConfig) Validate

func (c ServiceConfig) Validate() error

Validate ensures pipline definitions are consistent.

type SplitterConfig

type SplitterConfig struct {
	Kind        string         `json:"kind" yaml:"kind"`
	DPI         int            `json:"dpi" yaml:"dpi"`
	BatchPages  int            `json:"batch_pages" yaml:"batch_pages"`
	Options     map[string]any `json:"options" yaml:"options"`
	MaxParallel int            `json:"max_parallel" yaml:"max_parallel"`
}

SplitterConfig controls PDF splitting behaviour.

func (SplitterConfig) Validate

func (c SplitterConfig) Validate() error

Validate ensures splitter configuration is valid.

type WorkerConfig

type WorkerConfig struct {
	MaxConcurrent int `json:"max_concurrent" yaml:"max_concurrent"`
	QueueSize     int `json:"queue_size" yaml:"queue_size"`
}

WorkerConfig sets worker-pool characteristics.

func (WorkerConfig) Validate

func (c WorkerConfig) Validate() error

Validate ensures worker configuration values make sense.

Jump to

Keyboard shortcuts

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