Documentation
¶
Overview ¶
Package xberg provides a reusable, context-aware facade over the native Xberg Go binding.
Index ¶
- Constants
- type Config
- type Document
- type Extractor
- func (extractor *Extractor) Config() Config
- func (extractor *Extractor) ExtractBytes(ctx context.Context, data []byte, options ...Option) (*Result, error)
- func (extractor *Extractor) ExtractFile(ctx context.Context, path string, options ...Option) (*Result, error)
- func (extractor *Extractor) ExtractReader(ctx context.Context, reader io.Reader, options ...Option) (*Result, error)
- type FileConfig
- type NativeConfig
- type Option
- func WithChunking(config native.ChunkingConfig) Option
- func WithFileConfig(config native.FileExtractionConfig) Option
- func WithFilename(filename string) Option
- func WithForceOCRPages(pages ...uint32) Option
- func WithMIMEType(mimeType string) Option
- func WithNativeFileConfig(apply func(*native.FileExtractionConfig)) Option
- func WithOCR(config native.OcrConfig) Option
- func WithOutputFormat(format native.OutputFormat) Option
- func WithPDF(config native.PdfConfig) Option
- func WithPages(config native.PageConfig) Option
- func WithTimeout(timeout time.Duration) Option
- type Result
Constants ¶
const ( // DefaultMaxInputBytes limits untrusted reader and file inputs to 256 MiB. DefaultMaxInputBytes int64 = 256 << 20 // DefaultSpillToDiskThreshold avoids the native binding's JSON byte-array // amplification for inputs larger than 8 MiB. DefaultSpillToDiskThreshold int64 = 8 << 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Native native.ExtractionConfig
// MaxInputBytes is the maximum accepted file or reader size. Zero uses
// DefaultMaxInputBytes. A negative value disables this facade-level limit;
// Xberg's SecurityLimits still apply.
MaxInputBytes int64
// SpillToDiskThreshold controls when ExtractReader switches from memory to
// a temporary file. Zero uses DefaultSpillToDiskThreshold. A negative value
// keeps the whole reader in memory.
SpillToDiskThreshold int64
// TempDir optionally selects where spilled reader inputs are stored.
TempDir string
}
Config contains process-wide extraction defaults. Native is intentionally exposed as an escape hatch so callers can use new Xberg capabilities without waiting for this package to add a wrapper for every field.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns RAG-friendly defaults while leaving OCR, chunking, image extraction, and model-backed features opt-in.
type Document ¶
type Document = native.ExtractedDocument
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor is safe for concurrent use. Configuration is cloned during New and per-call overrides are allocated for every extraction.
func (*Extractor) ExtractBytes ¶
func (extractor *Extractor) ExtractBytes(ctx context.Context, data []byte, options ...Option) (*Result, error)
ExtractBytes extracts an in-memory document. Filename and MIME hints are strongly recommended for ZIP-container Office files.
func (*Extractor) ExtractFile ¶
func (extractor *Extractor) ExtractFile(ctx context.Context, path string, options ...Option) (*Result, error)
ExtractFile extracts a local regular file without first loading it into Go memory.
func (*Extractor) ExtractReader ¶
func (extractor *Extractor) ExtractReader(ctx context.Context, reader io.Reader, options ...Option) (*Result, error)
ExtractReader consumes reader. Small inputs stay in memory; larger inputs are transparently spooled to a temporary file to bound memory amplification.
type FileConfig ¶
type FileConfig = native.FileExtractionConfig
type NativeConfig ¶
type NativeConfig = native.ExtractionConfig
type Option ¶
type Option func(*extractOptions) error
Option customizes one extraction without mutating the Extractor defaults.
func WithChunking ¶
func WithChunking(config native.ChunkingConfig) Option
func WithFileConfig ¶
func WithFileConfig(config native.FileExtractionConfig) Option
WithFileConfig replaces the per-file native Xberg overrides.
func WithFilename ¶
func WithForceOCRPages ¶
func WithMIMEType ¶
func WithNativeFileConfig ¶
func WithNativeFileConfig(apply func(*native.FileExtractionConfig)) Option
WithNativeFileConfig applies an advanced native Xberg override after the other options that precede it.
func WithOutputFormat ¶
func WithOutputFormat(format native.OutputFormat) Option
func WithPages ¶
func WithPages(config native.PageConfig) Option
func WithTimeout ¶
type Result ¶
type Result = native.ExtractionResult
Result and related aliases preserve access to all native Xberg information.