Documentation
¶
Overview ¶
Package state provides application state management with support for both global singleton access (backward compatibility) and dependency injection patterns.
Index ¶
- Variables
- func GetAlpineMirror() *url.URL
- func GetAsyncBenchmarkEnabled() bool
- func GetCentOSMirror() *url.URL
- func GetDebianMirror() *url.URL
- func GetDisableBuiltinDistros() bool
- func GetProxyMode() int
- func GetUbuntuMirror() *url.URL
- func GetUbuntuPortsMirror() *url.URL
- func ResetAlpineMirror()
- func ResetCentOSMirror()
- func ResetDebianMirror()
- func ResetUbuntuMirror()
- func ResetUbuntuPortsMirror()
- func SetAlpineMirror(input string)
- func SetAsyncBenchmarkEnabled(enabled bool)
- func SetCentOSMirror(input string)
- func SetDebianMirror(input string)
- func SetDisableBuiltinDistros(disabled bool)
- func SetGlobal(state *AppState)
- func SetProxyMode(mode int)
- func SetUbuntuMirror(input string)
- func SetUbuntuPortsMirror(input string)
- type AppState
- func (s *AppState) Clone() *AppState
- func (s *AppState) GetAsyncBenchmarkEnabled() bool
- func (s *AppState) GetDisableBuiltinDistros() bool
- func (s *AppState) GetMirror(distType int) *url.URL
- func (s *AppState) GetProxyMode() int
- func (s *AppState) ResetAll()
- func (s *AppState) SetAsyncBenchmarkEnabled(enabled bool)
- func (s *AppState) SetDisableBuiltinDistros(disabled bool)
- func (s *AppState) SetMirror(distType int, input string)
- func (s *AppState) SetProxyMode(mode int)
- type MirrorState
Constants ¶
This section is empty.
Variables ¶
var ( // UbuntuMirror provides backward compatible access to Ubuntu mirror state UbuntuMirror = &mirrorProxy{distType: distro.TYPE_LINUX_DISTROS_UBUNTU} // UbuntuPortsMirror provides backward compatible access to Ubuntu Ports mirror state UbuntuPortsMirror = &mirrorProxy{distType: distro.TYPE_LINUX_DISTROS_UBUNTU_PORTS} // DebianMirror provides backward compatible access to Debian mirror state DebianMirror = &mirrorProxy{distType: distro.TYPE_LINUX_DISTROS_DEBIAN} // CentOSMirror provides backward compatible access to CentOS mirror state CentOSMirror = &mirrorProxy{distType: distro.TYPE_LINUX_DISTROS_CENTOS} // AlpineMirror provides backward compatible access to Alpine mirror state AlpineMirror = &mirrorProxy{distType: distro.TYPE_LINUX_DISTROS_ALPINE} )
These variables maintain backward compatibility with existing code that accesses mirrors directly. They delegate to the global AppState.
Functions ¶
func GetAlpineMirror ¶
func GetAsyncBenchmarkEnabled ¶
func GetAsyncBenchmarkEnabled() bool
func GetCentOSMirror ¶
func GetDebianMirror ¶
func GetDisableBuiltinDistros ¶ added in v0.11.1
func GetDisableBuiltinDistros() bool
func GetProxyMode ¶
func GetProxyMode() int
func GetUbuntuMirror ¶
func GetUbuntuPortsMirror ¶
func ResetAlpineMirror ¶
func ResetAlpineMirror()
func ResetCentOSMirror ¶
func ResetCentOSMirror()
func ResetDebianMirror ¶
func ResetDebianMirror()
func ResetUbuntuMirror ¶
func ResetUbuntuMirror()
func ResetUbuntuPortsMirror ¶
func ResetUbuntuPortsMirror()
func SetAlpineMirror ¶
func SetAlpineMirror(input string)
func SetAsyncBenchmarkEnabled ¶
func SetAsyncBenchmarkEnabled(enabled bool)
func SetCentOSMirror ¶
func SetCentOSMirror(input string)
func SetDebianMirror ¶
func SetDebianMirror(input string)
func SetDisableBuiltinDistros ¶ added in v0.11.1
func SetDisableBuiltinDistros(disabled bool)
func SetGlobal ¶
func SetGlobal(state *AppState)
SetGlobal replaces the global AppState instance. This is useful for testing or when you want to use a custom state instance. This function is thread-safe and can be called concurrently with Global().
func SetProxyMode ¶
func SetProxyMode(mode int)
func SetUbuntuMirror ¶
func SetUbuntuMirror(input string)
func SetUbuntuPortsMirror ¶
func SetUbuntuPortsMirror(input string)
Types ¶
type AppState ¶
type AppState struct {
Ubuntu *MirrorState
UbuntuPorts *MirrorState
Debian *MirrorState
CentOS *MirrorState
Alpine *MirrorState
// contains filtered or unexported fields
}
AppState manages the complete application state including proxy mode and mirror configurations for all supported distributions. This struct supports dependency injection for better testability.
func Global ¶
func Global() *AppState
Global returns the global AppState instance. This is primarily for dependency injection scenarios where you need to pass the state explicitly.
func NewAppState ¶
func NewAppState() *AppState
NewAppState creates a new AppState instance with initialized mirror states
func (*AppState) GetAsyncBenchmarkEnabled ¶
GetAsyncBenchmarkEnabled returns whether async mirror benchmarking is enabled
func (*AppState) GetDisableBuiltinDistros ¶ added in v0.11.1
GetDisableBuiltinDistros returns whether built-in distributions are disabled
func (*AppState) GetProxyMode ¶
GetProxyMode returns the current proxy mode
func (*AppState) SetAsyncBenchmarkEnabled ¶
SetAsyncBenchmarkEnabled sets whether async mirror benchmarking is enabled
func (*AppState) SetDisableBuiltinDistros ¶ added in v0.11.1
SetDisableBuiltinDistros sets whether built-in distributions are disabled
func (*AppState) SetProxyMode ¶
SetProxyMode sets the proxy mode
type MirrorState ¶
type MirrorState struct {
// contains filtered or unexported fields
}
MirrorState manages mirror URL states for a specific distribution
func NewMirrorState ¶
func NewMirrorState(distType int) *MirrorState
NewMirrorState creates a new MirrorState instance
func (*MirrorState) Clone ¶
func (m *MirrorState) Clone() *MirrorState
Clone creates a copy of the MirrorState