Documentation
¶
Index ¶
- type BatchConfig
- type BatchManager
- func (bm *BatchManager) AddCopyOperation(src, dst string, opts *operations.CopyOptions) error
- func (bm *BatchManager) AddOperation(op *Operation) error
- func (bm *BatchManager) Cancel()
- func (bm *BatchManager) Execute() (*BatchStats, error)
- func (bm *BatchManager) GetOperations() []*Operation
- func (bm *BatchManager) GetStats() *BatchStats
- func (bm *BatchManager) LoadFromFile(filename string) error
- func (bm *BatchManager) OnComplete(fn func(*BatchStats))
- func (bm *BatchManager) OnError(fn func(*Operation, error))
- func (bm *BatchManager) OnOperation(fn func(*Operation))
- func (bm *BatchManager) OnProgress(fn func(*BatchStats))
- func (bm *BatchManager) SaveToFile(filename string) error
- type BatchOperationSpec
- type BatchSpec
- type BatchStats
- type Operation
- type OperationStatus
- type OperationType
- type Worker
- type WorkerStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchConfig ¶
type BatchConfig struct {
Concurrency int `json:"concurrency"`
ContinueOnError bool `json:"continue_on_error"`
Retries int `json:"retries"`
Timeout time.Duration `json:"timeout"`
DryRun bool `json:"dry_run"`
Quiet bool `json:"quiet"`
Interactive bool `json:"interactive"`
}
BatchConfig contains configuration for batch operations
func DefaultBatchConfig ¶
func DefaultBatchConfig() *BatchConfig
DefaultBatchConfig returns default batch configuration
type BatchManager ¶
type BatchManager struct {
// contains filtered or unexported fields
}
BatchManager manages and executes batch operations
func NewBatchManager ¶
func NewBatchManager(config *BatchConfig) *BatchManager
NewBatchManager creates a new batch manager
func (*BatchManager) AddCopyOperation ¶
func (bm *BatchManager) AddCopyOperation(src, dst string, opts *operations.CopyOptions) error
AddCopyOperation adds a copy operation to the batch
func (*BatchManager) AddOperation ¶
func (bm *BatchManager) AddOperation(op *Operation) error
AddOperation adds an operation to the batch
func (*BatchManager) Execute ¶
func (bm *BatchManager) Execute() (*BatchStats, error)
Execute runs all operations in the batch
func (*BatchManager) GetOperations ¶
func (bm *BatchManager) GetOperations() []*Operation
GetOperations returns all operations
func (*BatchManager) GetStats ¶
func (bm *BatchManager) GetStats() *BatchStats
GetStats returns current statistics
func (*BatchManager) LoadFromFile ¶
func (bm *BatchManager) LoadFromFile(filename string) error
LoadFromFile loads operations from a JSON file
func (*BatchManager) OnComplete ¶
func (bm *BatchManager) OnComplete(fn func(*BatchStats))
func (*BatchManager) OnError ¶
func (bm *BatchManager) OnError(fn func(*Operation, error))
func (*BatchManager) OnOperation ¶
func (bm *BatchManager) OnOperation(fn func(*Operation))
func (*BatchManager) OnProgress ¶
func (bm *BatchManager) OnProgress(fn func(*BatchStats))
Callback setters
func (*BatchManager) SaveToFile ¶
func (bm *BatchManager) SaveToFile(filename string) error
SaveToFile saves current operations to a JSON file
type BatchOperationSpec ¶
type BatchOperationSpec struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Source string `json:"source"`
Destination string `json:"destination,omitempty"`
Options map[string]interface{} `json:"options,omitempty"`
}
BatchOperationSpec represents an operation in the specification
type BatchSpec ¶
type BatchSpec struct {
Config *BatchConfig `json:"config,omitempty"`
Operations []BatchOperationSpec `json:"operations"`
}
BatchSpec represents a batch specification file
type BatchStats ¶
type BatchStats struct {
Total int32 `json:"total"`
Pending int32 `json:"pending"`
Running int32 `json:"running"`
Completed int32 `json:"completed"`
Failed int32 `json:"failed"`
Skipped int32 `json:"skipped"`
Cancelled int32 `json:"cancelled"`
TotalSize int64 `json:"total_size"`
ProcessedSize int64 `json:"processed_size"`
TotalDuration time.Duration `json:"total_duration"`
AverageSpeed float64 `json:"average_speed_mbps"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time,omitempty"`
Progress float64 `json:"progress"`
ETA time.Duration `json:"eta"`
}
BatchStats contains statistics about batch operations
type Operation ¶
type Operation struct {
ID string `json:"id"`
Type OperationType `json:"type"`
Status OperationStatus `json:"status"`
Source string `json:"source"`
Destination string `json:"destination,omitempty"`
Options map[string]interface{} `json:"options,omitempty"`
Progress float64 `json:"progress"`
Error string `json:"error,omitempty"`
StartTime time.Time `json:"start_time,omitempty"`
EndTime time.Time `json:"end_time,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
Size int64 `json:"size,omitempty"`
Speed float64 `json:"speed_mbps,omitempty"`
}
Operation represents a single operation in a batch
type OperationStatus ¶
type OperationStatus string
OperationStatus defines the status of an operation
const ( StatusPending OperationStatus = "pending" StatusRunning OperationStatus = "running" StatusCompleted OperationStatus = "completed" StatusFailed OperationStatus = "failed" StatusSkipped OperationStatus = "skipped" StatusCancelled OperationStatus = "cancelled" )
type OperationType ¶
type OperationType string
OperationType defines different types of batch operations
const ( OperationTypeCopy OperationType = "copy" OperationTypeMove OperationType = "move" OperationTypeDelete OperationType = "delete" OperationTypeUpload OperationType = "upload" OperationTypeDownload OperationType = "download" OperationTypeSync OperationType = "sync" )
type Worker ¶
type Worker struct {
ID int
// contains filtered or unexported fields
}
Worker represents a worker that processes operations
func NewWorker ¶
func NewWorker(id int, queue chan *Operation, results chan *Operation, config *BatchConfig) *Worker
NewWorker creates a new worker
func (*Worker) GetStats ¶
func (w *Worker) GetStats() *WorkerStats
GetStats returns the worker's statistics
type WorkerStats ¶
type WorkerStats struct {
Processed int32 `json:"processed"`
Completed int32 `json:"completed"`
Failed int32 `json:"failed"`
Skipped int32 `json:"skipped"`
Cancelled int32 `json:"cancelled"`
TotalDuration time.Duration `json:"total_duration"`
AverageSpeed float64 `json:"average_speed_mbps"`
BytesProcessed int64 `json:"bytes_processed"`
StartTime time.Time `json:"start_time"`
LastActivity time.Time `json:"last_activity"`
}
WorkerStats contains statistics for a worker