state

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages persistent state with atomic saves.

func NewManager

func NewManager(workspace string) *Manager

NewManager creates a new state manager for the given workspace.

func (*Manager) GetLastChannel

func (sm *Manager) GetLastChannel() string

GetLastChannel returns the last channel from the state.

func (*Manager) GetLastChatID

func (sm *Manager) GetLastChatID() string

GetLastChatID returns the last chat ID from the state.

func (*Manager) GetTimestamp

func (sm *Manager) GetTimestamp() time.Time

GetTimestamp returns the timestamp of the last state update.

func (*Manager) SetLastChannel

func (sm *Manager) SetLastChannel(channel string) error

SetLastChannel atomically updates the last channel and saves the state. This method uses a temp file + rename pattern for atomic writes, ensuring that the state file is never corrupted even if the process crashes.

func (*Manager) SetLastChatID

func (sm *Manager) SetLastChatID(chatID string) error

SetLastChatID atomically updates the last chat ID and saves the state.

type State

type State struct {
	// LastChannel is the last channel used for communication
	LastChannel string `json:"last_channel,omitempty"`

	// LastChatID is the last chat ID used for communication
	LastChatID string `json:"last_chat_id,omitempty"`

	// Timestamp is the last time this state was updated
	Timestamp time.Time `json:"timestamp"`
}

State represents the persistent state for a workspace. It includes information about the last active channel/chat.

Jump to

Keyboard shortcuts

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