Documentation
¶
Overview ¶
Package operations provides tracking for long-running operations with real-time progress updates via Server-Sent Events (SSE).
Index ¶
- func ServeSSE(w http.ResponseWriter, r *http.Request, opID string)
- type Manager
- type Operation
- func (op *Operation) Cancel()
- func (op *Operation) Complete(result map[string]any)
- func (op *Operation) Context() context.Context
- func (op *Operation) Fail(err error)
- func (op *Operation) GetProgress() ProgressUpdate
- func (op *Operation) ID() string
- func (op *Operation) NextPhase()
- func (op *Operation) SetMetadata(key string, value any)
- func (op *Operation) Subscribe() <-chan ProgressUpdate
- func (op *Operation) Unsubscribe(ch <-chan ProgressUpdate)
- func (op *Operation) UpdateBytes(done, total int64)
- func (op *Operation) UpdateItems(done, total int)
- func (op *Operation) UpdateProgress(progress int, message string)
- type OperationStatus
- type OperationType
- type Phase
- type ProgressUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles operation tracking
func (*Manager) GetOperation ¶
GetOperation retrieves an operation by ID
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation tracks a long-running operation
func (*Operation) Complete ¶
Complete marks the operation as complete
func (*Operation) Context ¶
Context returns the operation's context
func (*Operation) GetProgress ¶
func (op *Operation) GetProgress() ProgressUpdate
GetProgress returns current progress state
func (*Operation) SetMetadata ¶
SetMetadata sets operation metadata
func (*Operation) Subscribe ¶
func (op *Operation) Subscribe() <-chan ProgressUpdate
Subscribe to operation progress updates
func (*Operation) Unsubscribe ¶
func (op *Operation) Unsubscribe(ch <-chan ProgressUpdate)
Unsubscribe from operation updates
func (*Operation) UpdateBytes ¶
UpdateBytes updates byte progress
func (*Operation) UpdateItems ¶
UpdateItems updates item progress
type OperationStatus ¶
type OperationStatus string
OperationStatus represents the current status of an operation
const ( StatusPending OperationStatus = "pending" StatusRunning OperationStatus = "running" StatusComplete OperationStatus = "complete" StatusFailed OperationStatus = "failed" StatusCancelled OperationStatus = "cancelled" )
type OperationType ¶
type OperationType string
OperationType represents the type of long-running operation
const ( OpChunkedUpload OperationType = "chunked_upload" OpRepoMirrorSync OperationType = "mirror_sync" OpRepoPush OperationType = "repo_push" OpRepoClone OperationType = "repo_clone" OpWikiGenerate OperationType = "wiki_generate" OpBatchOperation OperationType = "batch_operation" )
type Phase ¶
type Phase struct {
Name string `json:"name"`
Status OperationStatus `json:"status"`
Progress int `json:"progress"` // 0-100
Message string `json:"message,omitempty"`
}
Phase represents a phase within an operation
type ProgressUpdate ¶
type ProgressUpdate struct {
OperationID string `json:"operation_id"`
Type OperationType `json:"type"`
Status OperationStatus `json:"status"`
CurrentPhase string `json:"current_phase,omitempty"`
Phases []Phase `json:"phases,omitempty"`
Progress int `json:"progress"` // Overall progress 0-100
BytesTotal int64 `json:"bytes_total,omitempty"`
BytesDone int64 `json:"bytes_done,omitempty"`
ItemsTotal int `json:"items_total,omitempty"`
ItemsDone int `json:"items_done,omitempty"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
EstimatedETA *time.Time `json:"estimated_eta,omitempty"`
SpeedBPS int64 `json:"speed_bps,omitempty"` // bytes per second
Metadata map[string]any `json:"metadata,omitempty"`
}
ProgressUpdate represents a progress update event
Source Files
¶
- progress.go