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 GetCentOSMirror() *url.URL
- func GetDebianMirror() *url.URL
- 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 SetCentOSMirror(input string)
- func SetDebianMirror(input string)
- func SetGlobal(state *AppState)
- func SetProxyMode(mode int)
- func SetUbuntuMirror(input string)
- func SetUbuntuPortsMirror(input string)
- type AppState
- 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 GetCentOSMirror ¶
func GetDebianMirror ¶
func GetProxyMode ¶
func GetProxyMode() int
func GetUbuntuMirror ¶
func GetUbuntuPortsMirror ¶ added in v0.9.0
func ResetAlpineMirror ¶
func ResetAlpineMirror()
func ResetCentOSMirror ¶
func ResetCentOSMirror()
func ResetDebianMirror ¶
func ResetDebianMirror()
func ResetUbuntuMirror ¶
func ResetUbuntuMirror()
func ResetUbuntuPortsMirror ¶ added in v0.9.0
func ResetUbuntuPortsMirror()
func SetAlpineMirror ¶
func SetAlpineMirror(input string)
func SetCentOSMirror ¶
func SetCentOSMirror(input string)
func SetDebianMirror ¶
func SetDebianMirror(input string)
func SetGlobal ¶ added in v0.9.0
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 ¶ added in v0.9.0
func SetUbuntuPortsMirror(input string)
Types ¶
type AppState ¶ added in v0.9.0
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 ¶ added in v0.9.0
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 ¶ added in v0.9.0
func NewAppState() *AppState
NewAppState creates a new AppState instance with initialized mirror states
func (*AppState) GetMirror ¶ added in v0.9.0
GetMirror returns the mirror URL for a specific distribution
func (*AppState) GetProxyMode ¶ added in v0.9.0
GetProxyMode returns the current proxy mode
func (*AppState) ResetAll ¶ added in v0.9.0
func (s *AppState) ResetAll()
ResetAll resets all mirror states
func (*AppState) SetMirror ¶ added in v0.9.0
SetMirror sets the mirror URL for a specific distribution
func (*AppState) SetProxyMode ¶ added in v0.9.0
SetProxyMode sets the proxy mode
type MirrorState ¶ added in v0.9.0
type MirrorState struct {
// contains filtered or unexported fields
}
MirrorState manages mirror URL states for a specific distribution
func NewMirrorState ¶ added in v0.9.0
func NewMirrorState(distType int) *MirrorState
NewMirrorState creates a new MirrorState instance
func (*MirrorState) Clone ¶ added in v0.9.0
func (m *MirrorState) Clone() *MirrorState
Clone creates a copy of the MirrorState
func (*MirrorState) Get ¶ added in v0.9.0
func (m *MirrorState) Get() *url.URL
Get returns the current mirror URL
func (*MirrorState) Reset ¶ added in v0.9.0
func (m *MirrorState) Reset()
Reset clears the mirror URL
func (*MirrorState) Set ¶ added in v0.9.0
func (m *MirrorState) Set(input string)
Set updates the mirror URL