state

package
v1.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package state implements state for debugging.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultState is the default state.
	DefaultState = State{
		Channels: make(map[string]*ChannelState),
	}
)

Functions

This section is empty.

Types

type ChannelState

type ChannelState struct {
	DownloadState DownloadState          `json:"state"`
	Extra         map[string]interface{} `json:"extra,omitempty"`
	Errors        []DownloadError        `json:"errors_log"`
}

ChannelState represents the state of a channel.

type DownloadError added in v0.5.1

type DownloadError struct {
	Timestamp string `json:"timestamp"`
	Error     string `json:"error"`
}

DownloadError represents an error during a download.

type DownloadState

type DownloadState int

DownloadState represents the state of a download.

const (
	// DownloadStateUnspecified is used when the download state is unspecified.
	DownloadStateUnspecified DownloadState = iota
	// DownloadStateIdle is used when the download is idle.
	DownloadStateIdle
	// DownloadStatePreparingFiles is used when the download is preparing files.
	DownloadStatePreparingFiles
	// DownloadStateDownloading is used when the download is downloading.
	DownloadStateDownloading
	// DownloadStatePostProcessing is used when the download is post processing.
	DownloadStatePostProcessing
	// DownloadStateFinished is used when the download is finished.
	DownloadStateFinished
	// DownloadStateCanceled is used when the download is canceled.
	DownloadStateCanceled
)

func DownloadStateFromString

func DownloadStateFromString(s string) DownloadState

DownloadStateFromString returns a DownloadState from a string.

func (DownloadState) MarshalJSON

func (d DownloadState) MarshalJSON() ([]byte, error)

MarshalJSON marshals a DownloadState into a string.

func (DownloadState) String

func (d DownloadState) String() string

String returns a string representation of a DownloadState.

func (*DownloadState) UnmarshalJSON

func (d *DownloadState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a string into a DownloadState.

type State

type State struct {
	Channels map[string]*ChannelState `json:"channels"`
	// contains filtered or unexported fields
}

State represents the state of the program.

func (*State) GetChannelState added in v1.2.0

func (s *State) GetChannelState(name string) DownloadState

GetChannelState returns the state for a channel.

func (*State) ReadState added in v1.2.0

func (s *State) ReadState() *State

ReadState returns the current state.

func (*State) SetChannelError added in v1.2.0

func (s *State) SetChannelError(name string, err error)

SetChannelError sets an error for a channel.

func (*State) SetChannelState added in v1.2.0

func (s *State) SetChannelState(name string, state DownloadState, extra map[string]interface{})

SetChannelState sets the state for a channel.

Jump to

Keyboard shortcuts

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