Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportProgress ¶
ReportProgress is a helper function to report progress from within handlers
Types ¶
type BatchedReporter ¶
type BatchedReporter struct {
*Batcher
}
BatchedReporter wraps a Reporter with batching capabilities
func NewBatchedReporter ¶
func NewBatchedReporter(requestID, connectionID string, connManager ConnectionManager, opts ...BatcherOption) *BatchedReporter
NewBatchedReporter creates a new batched reporter
type Batcher ¶
type Batcher struct {
// contains filtered or unexported fields
}
Batcher batches progress updates to reduce WebSocket message volume
func NewBatcher ¶
func NewBatcher(reporter Reporter, opts ...BatcherOption) *Batcher
NewBatcher creates a new progress update batcher
func (*Batcher) SetMetadata ¶
SetMetadata sets metadata for future updates
type BatcherOption ¶
type BatcherOption func(*Batcher)
BatcherOption configures the batcher
func WithFlushThreshold ¶
func WithFlushThreshold(threshold float64) BatcherOption
WithFlushThreshold sets the percentage threshold for immediate flush
func WithInterval ¶
func WithInterval(interval time.Duration) BatcherOption
WithInterval sets the batch interval
func WithMaxBatch ¶
func WithMaxBatch(max int) BatcherOption
WithMaxBatch sets the maximum batch size
type ConnectionManager ¶
type ConnectionManager interface {
Send(ctx context.Context, connectionID string, message interface{}) error
IsActive(ctx context.Context, connectionID string) bool
}
ConnectionManager interface for sending WebSocket messages
type DefaultReporter ¶
type DefaultReporter struct {
// contains filtered or unexported fields
}
DefaultReporter implements the Reporter interface
func NewReporter ¶
func NewReporter(requestID, connectionID string, connManager ConnectionManager) *DefaultReporter
NewReporter creates a new progress reporter
func (*DefaultReporter) Complete ¶
func (r *DefaultReporter) Complete(result interface{}) error
Complete sends a completion notification
func (*DefaultReporter) Fail ¶
func (r *DefaultReporter) Fail(err error) error
Fail sends a failure notification
func (*DefaultReporter) Report ¶
func (r *DefaultReporter) Report(percentage float64, message string) error
Report sends a progress update
func (*DefaultReporter) SetMetadata ¶
func (r *DefaultReporter) SetMetadata(key string, value interface{}) error
SetMetadata adds metadata to future progress updates
type Reporter ¶
type Reporter interface {
// Report sends a progress update with percentage and message
Report(percentage float64, message string) error
// SetMetadata adds metadata to the progress update
SetMetadata(key string, value interface{}) error
// Complete marks the request as complete with the result
Complete(result interface{}) error
// Fail marks the request as failed with an error
Fail(err error) error
}
Reporter provides progress reporting functionality for async requests