Documentation ¶
Overview ¶
Package state implements state for debugging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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"` Labels map[string]string `json:"labels,omitempty"` Errors []DownloadError `json:"errors_log"` }
ChannelState represents the state of a channel.
type DownloadError ¶
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 SetChannelStateOptions ¶
type SetChannelStateOptions func(*setChannelStateOptions)
SetChannelStateOptions represents options for SetChannelState.
func WithExtra ¶
func WithExtra(extra map[string]interface{}) SetChannelStateOptions
WithExtra sets extra data for a channel.
func WithLabels ¶
func WithLabels(labels map[string]string) SetChannelStateOptions
WithLabels sets labels for a channel.
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 ¶
func (s *State) GetChannelState(name string) DownloadState
GetChannelState returns the state for a channel.
func (*State) SetChannelError ¶
SetChannelError sets an error for a channel.
func (*State) SetChannelState ¶
func (s *State) SetChannelState( name string, state DownloadState, opts ...SetChannelStateOptions, )
SetChannelState sets the state for a channel.