state

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package state provides application state management with support for both global singleton access (backward compatibility) and dependency injection patterns.

Index

Constants

This section is empty.

Variables

View Source
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 GetAlpineMirror() *url.URL

func GetAsyncBenchmarkEnabled

func GetAsyncBenchmarkEnabled() bool

func GetCentOSMirror

func GetCentOSMirror() *url.URL

func GetDebianMirror

func GetDebianMirror() *url.URL

func GetDisableBuiltinDistros added in v0.11.1

func GetDisableBuiltinDistros() bool

func GetProxyMode

func GetProxyMode() int

func GetUbuntuMirror

func GetUbuntuMirror() *url.URL

func GetUbuntuPortsMirror

func GetUbuntuPortsMirror() *url.URL

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) Clone

func (s *AppState) Clone() *AppState

Clone creates a deep copy of the AppState

func (*AppState) GetAsyncBenchmarkEnabled

func (s *AppState) GetAsyncBenchmarkEnabled() bool

GetAsyncBenchmarkEnabled returns whether async mirror benchmarking is enabled

func (*AppState) GetDisableBuiltinDistros added in v0.11.1

func (s *AppState) GetDisableBuiltinDistros() bool

GetDisableBuiltinDistros returns whether built-in distributions are disabled

func (*AppState) GetMirror

func (s *AppState) GetMirror(distType int) *url.URL

GetMirror returns the mirror URL for a specific distribution

func (*AppState) GetProxyMode

func (s *AppState) GetProxyMode() int

GetProxyMode returns the current proxy mode

func (*AppState) ResetAll

func (s *AppState) ResetAll()

ResetAll resets all mirror states

func (*AppState) SetAsyncBenchmarkEnabled

func (s *AppState) SetAsyncBenchmarkEnabled(enabled bool)

SetAsyncBenchmarkEnabled sets whether async mirror benchmarking is enabled

func (*AppState) SetDisableBuiltinDistros added in v0.11.1

func (s *AppState) SetDisableBuiltinDistros(disabled bool)

SetDisableBuiltinDistros sets whether built-in distributions are disabled

func (*AppState) SetMirror

func (s *AppState) SetMirror(distType int, input string)

SetMirror sets the mirror URL for a specific distribution

func (*AppState) SetProxyMode

func (s *AppState) SetProxyMode(mode int)

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

func (*MirrorState) Get

func (m *MirrorState) Get() *url.URL

Get returns the current mirror URL

func (*MirrorState) Reset

func (m *MirrorState) Reset()

Reset clears the mirror URL

func (*MirrorState) Set

func (m *MirrorState) Set(input string)

Set updates the mirror URL

Jump to

Keyboard shortcuts

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