Files
example-eino/adk/internal/agent/checkpoint.go
T

34 lines
667 B
Go

package agent
import (
"context"
"sync"
)
// checkpointStore 只保存当前终端进程中的暂停状态,退出后不再保留。
type checkpointStore struct {
mu sync.Mutex
data map[string][]byte
}
func (s *checkpointStore) Get(_ context.Context, id string) ([]byte, bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
data, ok := s.data[id]
return data, ok, nil
}
func (s *checkpointStore) Set(_ context.Context, id string, data []byte) error {
s.mu.Lock()
defer s.mu.Unlock()
s.data[id] = data
return nil
}
func (s *checkpointStore) Delete(_ context.Context, id string) error {
s.mu.Lock()
defer s.mu.Unlock()
delete(s.data, id)
return nil
}