Documentation
¶
Index ¶
- type Manager
- func (sm *Manager) GetLastChannel() string
- func (sm *Manager) GetLastChatID() string
- func (sm *Manager) GetOwnerChat() (channel, chatID string)
- func (sm *Manager) GetTimestamp() time.Time
- func (sm *Manager) SetLastChannel(channel string) error
- func (sm *Manager) SetLastChatID(chatID string) error
- func (sm *Manager) SetOwnerChat(channel, chatID string) error
- type State
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.
Several managers can share one state file — the agent's, the heartbeat's and the device service's — so a manager reads the file again on every get and before every set: each sees what the others wrote.
func NewManager ¶
NewManager creates a new state manager for the given workspace.
func (*Manager) GetLastChannel ¶
GetLastChannel returns the last channel from the state.
func (*Manager) GetLastChatID ¶
GetLastChatID returns the last chat ID from the state.
func (*Manager) GetOwnerChat ¶
GetOwnerChat returns the chat the owner last wrote from; both are empty when none is known.
func (*Manager) GetTimestamp ¶
GetTimestamp returns the timestamp of the last state update.
func (*Manager) SetLastChannel ¶
SetLastChannel records the last channel and saves the state. The file is written only when the channel changed: every turn records its channel, and most turns come from the channel the previous one did.
func (*Manager) SetLastChatID ¶
SetLastChatID records the last chat ID and saves the state when it changed.
func (*Manager) SetOwnerChat ¶
SetOwnerChat records the chat the owner last wrote from, saving the state when it changed.
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"`
// OwnerChannel and OwnerChatID name the chat the owner last wrote from:
// where notices meant for the owner, and approval requests, go.
OwnerChannel string `json:"owner_channel,omitempty"`
OwnerChatID string `json:"owner_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.