Documentation
¶
Overview ¶
Package impexp provides import/export utilities for data migration, backup, and restore operations.
Index ¶
- func Backup(ctx context.Context, sources map[string]DataSource, outputDir string) error
- func Restore(ctx context.Context, backupDir string, sinks map[string]DataSink) error
- type DataSink
- type DataSource
- type DefaultExporter
- func (e *DefaultExporter) Export(ctx context.Context, data interface{}, w io.Writer, opts *Options) error
- func (e *DefaultExporter) ExportBatch(ctx context.Context, dataSource DataSource, w io.Writer, opts *Options) error
- func (e *DefaultExporter) ExportFile(ctx context.Context, data interface{}, filename string, opts *Options) error
- type DefaultImporter
- func (i *DefaultImporter) Import(ctx context.Context, r io.Reader, dest interface{}, opts *Options) error
- func (i *DefaultImporter) ImportBatch(ctx context.Context, r io.Reader, dataSink DataSink, opts *Options) error
- func (i *DefaultImporter) ImportFile(ctx context.Context, filename string, dest interface{}, opts *Options) error
- type Exporter
- type FilterFunc
- type Format
- type Importer
- type Options
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DataSink ¶
type DataSink interface {
// WriteBatch writes a batch of data
WriteBatch(ctx context.Context, batch []interface{}) error
}
DataSink receives data during batch import
type DataSource ¶
type DataSource interface {
// NextBatch returns the next batch of data
NextBatch(ctx context.Context, batchSize int) ([]interface{}, error)
// HasMore indicates if more data is available
HasMore() bool
}
DataSource provides data for batch export
type DefaultExporter ¶
type DefaultExporter struct{}
DefaultExporter implements the Exporter interface
func (*DefaultExporter) Export ¶
func (e *DefaultExporter) Export(ctx context.Context, data interface{}, w io.Writer, opts *Options) error
Export exports data to a writer
func (*DefaultExporter) ExportBatch ¶
func (e *DefaultExporter) ExportBatch(ctx context.Context, dataSource DataSource, w io.Writer, opts *Options) error
ExportBatch exports data in batches
func (*DefaultExporter) ExportFile ¶
func (e *DefaultExporter) ExportFile(ctx context.Context, data interface{}, filename string, opts *Options) error
ExportFile exports data to a file
type DefaultImporter ¶
type DefaultImporter struct{}
DefaultImporter implements the Importer interface
func (*DefaultImporter) Import ¶
func (i *DefaultImporter) Import(ctx context.Context, r io.Reader, dest interface{}, opts *Options) error
Import imports data from a reader
func (*DefaultImporter) ImportBatch ¶
func (i *DefaultImporter) ImportBatch(ctx context.Context, r io.Reader, dataSink DataSink, opts *Options) error
ImportBatch imports data in batches
func (*DefaultImporter) ImportFile ¶
func (i *DefaultImporter) ImportFile(ctx context.Context, filename string, dest interface{}, opts *Options) error
ImportFile imports data from a file
type Exporter ¶
type Exporter interface {
// Export exports data to a writer
Export(ctx context.Context, data interface{}, w io.Writer, opts *Options) error
// ExportFile exports data to a file
ExportFile(ctx context.Context, data interface{}, filename string, opts *Options) error
// ExportBatch exports data in batches
ExportBatch(ctx context.Context, dataSource DataSource, w io.Writer, opts *Options) error
}
Exporter handles data export operations
type FilterFunc ¶
type FilterFunc func(entity interface{}) bool
FilterFunc filters entities during export/import
type Importer ¶
type Importer interface {
// Import imports data from a reader
Import(ctx context.Context, r io.Reader, dest interface{}, opts *Options) error
// ImportFile imports data from a file
ImportFile(ctx context.Context, filename string, dest interface{}, opts *Options) error
// ImportBatch imports data in batches
ImportBatch(ctx context.Context, r io.Reader, dataSink DataSink, opts *Options) error
}
Importer handles data import operations
type Options ¶
type Options struct {
Format Format // Export format
Pretty bool // Pretty print JSON
Compress bool // Compress output
Filter FilterFunc // Filter function for selective export
Transform TransformFunc // Transform function for data manipulation
BatchSize int // Batch size for large datasets
Delimiter rune // CSV delimiter
Headers []string // CSV headers
MaxFileSize int64 // Maximum file size in bytes
Metadata map[string]string // Additional metadata
Version string // Export version for ZIP format (default "1.0")
}
Options configures import/export operations
type TransformFunc ¶
type TransformFunc func(entity interface{}) (interface{}, error)
TransformFunc transforms entities during export/import