SaveSnapshot 保存快照
(ctx context.Context, agentID string, snapshot types.Snapshot)
| 205 | |
| 206 | // SaveSnapshot 保存快照 |
| 207 | func (s *MySQLStore) SaveSnapshot(ctx context.Context, agentID string, snapshot types.Snapshot) error { |
| 208 | data, err := json.Marshal(snapshot) |
| 209 | if err != nil { |
| 210 | return fmt.Errorf("marshal snapshot: %w", err) |
| 211 | } |
| 212 | |
| 213 | record := AgentSnapshot{AgentID: agentID, SnapshotID: snapshot.ID, Data: string(data)} |
| 214 | return s.db.WithContext(ctx).Create(&record).Error |
| 215 | } |
| 216 | |
| 217 | // LoadSnapshot 加载快照 |
| 218 | func (s *MySQLStore) LoadSnapshot(ctx context.Context, agentID string, snapshotID string) (*types.Snapshot, error) { |