Help us shape the future of Go! Take the 2026 Go Developer Survey

state

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package state 提供轻量级的运行时状态持久化管理。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeartbeatState

type HeartbeatState struct {
	LastChannel string    `json:"last_channel"`      // 最近活跃的消息通道
	LastChatID  string    `json:"last_chat_id"`      // 最近活跃的聊天 ID
	SeenAt      time.Time `json:"seen_at,omitempty"` // 最近一次活跃的时间戳
}

HeartbeatState 存储最新的活跃聊天目标,用于心跳消息的定向投递。

type Manager

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

Manager 负责在磁盘上持久化轻量级的运行时状态。

func NewManager

func NewManager(baseDir string) *Manager

NewManager 在指定的基础目录下创建状态管理器,文件将存储在 <baseDir>/state 中。

func (*Manager) LoadHeartbeatState

func (m *Manager) LoadHeartbeatState() (HeartbeatState, error)

LoadHeartbeatState 从磁盘加载心跳状态。如果文件不存在或格式错误,将返回空状态。

func (*Manager) SaveHeartbeatState

func (m *Manager) SaveHeartbeatState(st HeartbeatState) error

SaveHeartbeatState 将最新的心跳状态写入磁盘。

Jump to

Keyboard shortcuts

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