sync: migrate ai-operator to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package handoff
|
||||
|
||||
import "sync"
|
||||
|
||||
type Store struct {
|
||||
mu sync.RWMutex
|
||||
requests map[string]HandoffRequest
|
||||
byCall map[string]string
|
||||
}
|
||||
|
||||
func NewStore() *Store {
|
||||
return &Store{requests: map[string]HandoffRequest{}, byCall: map[string]string{}}
|
||||
}
|
||||
|
||||
func (s *Store) Put(req HandoffRequest) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.requests[req.ID] = req
|
||||
s.byCall[req.CallID] = req.ID
|
||||
}
|
||||
|
||||
func (s *Store) Get(id string) (HandoffRequest, bool) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
req, ok := s.requests[id]
|
||||
return req, ok
|
||||
}
|
||||
|
||||
func (s *Store) GetByCall(callID string) (HandoffRequest, bool) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
id, ok := s.byCall[callID]
|
||||
if !ok {
|
||||
return HandoffRequest{}, false
|
||||
}
|
||||
req, ok := s.requests[id]
|
||||
return req, ok
|
||||
}
|
||||
|
||||
func (s *Store) DeleteByCall(callID string) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if id, ok := s.byCall[callID]; ok {
|
||||
delete(s.requests, id)
|
||||
delete(s.byCall, callID)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user