Documentation
¶
Index ¶
- func DefaultStatePath() string
- type PersistentProxyConfig
- type PersistentState
- type StateManager
- func (sm *StateManager) AddProxy(config PersistentProxyConfig)
- func (sm *StateManager) Clear() error
- func (sm *StateManager) Flush() error
- func (sm *StateManager) GetOverlayEndpoint() string
- func (sm *StateManager) GetProxies() []PersistentProxyConfig
- func (sm *StateManager) GetProxy(id string) (PersistentProxyConfig, bool)
- func (sm *StateManager) Load() error
- func (sm *StateManager) RemoveProxy(id string)
- func (sm *StateManager) Save() error
- func (sm *StateManager) SaveDebounced()
- func (sm *StateManager) SetOverlayEndpoint(endpoint string)
- func (sm *StateManager) State() PersistentState
- type StateManagerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultStatePath ¶
func DefaultStatePath() string
DefaultStatePath returns the default state file path.
Types ¶
type PersistentProxyConfig ¶
type PersistentProxyConfig struct {
ID string `json:"id"`
TargetURL string `json:"target_url"`
Port int `json:"port"`
MaxLogSize int `json:"max_log_size"`
Path string `json:"path"`
CreatedAt string `json:"created_at"`
}
PersistentProxyConfig stores the configuration needed to recreate a proxy.
type PersistentState ¶
type PersistentState struct {
Version int `json:"version"`
OverlayEndpoint string `json:"overlay_endpoint,omitempty"`
Proxies []PersistentProxyConfig `json:"proxies,omitempty"`
UpdatedAt string `json:"updated_at"`
}
PersistentState stores daemon state that should survive restarts.
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager handles persisting and restoring daemon state.
func NewStateManager ¶
func NewStateManager(config StateManagerConfig) *StateManager
NewStateManager creates a new state manager.
func (*StateManager) AddProxy ¶
func (sm *StateManager) AddProxy(config PersistentProxyConfig)
AddProxy adds a proxy configuration to state.
func (*StateManager) Flush ¶
func (sm *StateManager) Flush() error
Flush ensures any pending saves are written immediately.
func (*StateManager) GetOverlayEndpoint ¶
func (sm *StateManager) GetOverlayEndpoint() string
GetOverlayEndpoint returns the persisted overlay endpoint.
func (*StateManager) GetProxies ¶
func (sm *StateManager) GetProxies() []PersistentProxyConfig
GetProxies returns all persisted proxy configurations.
func (*StateManager) GetProxy ¶
func (sm *StateManager) GetProxy(id string) (PersistentProxyConfig, bool)
GetProxy returns a specific proxy configuration.
func (*StateManager) RemoveProxy ¶
func (sm *StateManager) RemoveProxy(id string)
RemoveProxy removes a proxy configuration from state.
func (*StateManager) SaveDebounced ¶
func (sm *StateManager) SaveDebounced()
SaveDebounced saves state with debouncing to avoid excessive writes.
func (*StateManager) SetOverlayEndpoint ¶
func (sm *StateManager) SetOverlayEndpoint(endpoint string)
SetOverlayEndpoint updates the overlay endpoint in state.
func (*StateManager) State ¶
func (sm *StateManager) State() PersistentState
State returns a copy of the current state.
type StateManagerConfig ¶
type StateManagerConfig struct {
// StatePath is the path to the state file.
// If empty, uses default location.
StatePath string
// SaveInterval is the minimum time between saves (debouncing).
SaveInterval time.Duration
// AutoLoad loads state on creation if true.
AutoLoad bool
}
StateManagerConfig configures the state manager.
func DefaultStateManagerConfig ¶
func DefaultStateManagerConfig() StateManagerConfig
DefaultStateManagerConfig returns sensible defaults.