progress

package
v0.0.0-...-769d336 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	PageID string
	Send   chan []byte
	Conn   *websocket.Conn
}

func (*Client) WritePump

func (c *Client) WritePump(ctx context.Context)

type Event

type Event struct {
	Type     string   `json:"type"`
	PageID   string   `json:"page_id"`
	Progress Snapshot `json:"progress"`
}

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub() *Hub

func (*Hub) Publish

func (h *Hub) Publish(pageID string, snap Snapshot)

func (*Hub) Register

func (h *Hub) Register(c *Client)

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) Unregister

func (h *Hub) Unregister(c *Client)

type ItemError

type ItemError struct {
	Path  string `json:"path,omitempty"`
	Code  string `json:"code,omitempty"`
	Error string `json:"error"`
}

type Publisher

type Publisher interface {
	Publish(pageID string, snap Snapshot)
}

type Reporter

type Reporter interface {
	SetOperation(op string, location string, total int)
	Add(delta int)
	Set(progress int)
	Error(err ItemError)
	Fatal(err error)
	Done()
}

type Snapshot

type Snapshot struct {
	TaskID      string      `json:"task_id"`
	Operation   string      `json:"operation"`
	Location    string      `json:"location,omitempty"`
	Total       int         `json:"total"`
	Progress    int         `json:"progress"`
	ProgressPct float64     `json:"progress_pct"`
	Rate        float64     `json:"rate"`
	ETASeconds  float64     `json:"eta_seconds,omitempty"`
	Done        bool        `json:"done,omitempty"`
	Fatal       string      `json:"fatal,omitempty"`
	Errors      []ItemError `json:"errors,omitempty"`
	StartedAt   time.Time   `json:"started_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(pageID, taskID string, pub Publisher) *Tracker

func (*Tracker) Add

func (t *Tracker) Add(delta int)

func (*Tracker) Done

func (t *Tracker) Done()

func (*Tracker) Error

func (t *Tracker) Error(err ItemError)

func (*Tracker) Fatal

func (t *Tracker) Fatal(err error)

func (*Tracker) Set

func (t *Tracker) Set(progress int)

func (*Tracker) SetOperation

func (t *Tracker) SetOperation(op string, location string, total int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL