MCPcopy Create free account
hub / github.com/astercloud/aster / UpdateState

Method UpdateState

pkg/session/inmemory.go:200–217  ·  view source on GitHub ↗

UpdateState 更新状态

(ctx context.Context, sessionID string, delta map[string]any)

Source from the content-addressed store, hash-verified

198
199// UpdateState 更新状态
200func (s *InMemoryService) UpdateState(ctx context.Context, sessionID string, delta map[string]any) error {
201 s.mu.Lock()
202 defer s.mu.Unlock()
203
204 session, ok := s.sessions[sessionID]
205 if !ok {
206 return ErrSessionNotFound
207 }
208
209 for k, v := range delta {
210 if err := session.state.Set(k, v); err != nil {
211 return fmt.Errorf("set state %s: %w", k, err)
212 }
213 }
214
215 session.lastUpdateTime = time.Now()
216 return nil
217}
218
219// inMemorySession 内存会话实现
220type inMemorySession struct {

Callers

nothing calls this directly

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected