Files
amcs/internal/mcpserver/eventstore.go
Hein f41c512f36 test(tools): add unit tests for error handling functions
* Implement tests for error functions like errRequiredField, errInvalidField, and errEntityNotFound.
* Ensure proper metadata is returned for various error scenarios.
* Validate error handling in CRM, Files, and other tools.
* Introduce tests for parsing stored file IDs and UUIDs.
* Enhance coverage for helper functions related to project resolution and session management.
2026-03-31 15:10:07 +02:00

43 lines
1.1 KiB
Go

package mcpserver
import (
"context"
"iter"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
type cleanupEventStore struct {
base mcp.EventStore
onSessionClosed func(string)
}
func newCleanupEventStore(base mcp.EventStore, onSessionClosed func(string)) mcp.EventStore {
return &cleanupEventStore{
base: base,
onSessionClosed: onSessionClosed,
}
}
func (s *cleanupEventStore) Open(ctx context.Context, sessionID, streamID string) error {
return s.base.Open(ctx, sessionID, streamID)
}
func (s *cleanupEventStore) Append(ctx context.Context, sessionID, streamID string, data []byte) error {
return s.base.Append(ctx, sessionID, streamID, data)
}
func (s *cleanupEventStore) After(ctx context.Context, sessionID, streamID string, index int) iter.Seq2[[]byte, error] {
return s.base.After(ctx, sessionID, streamID, index)
}
func (s *cleanupEventStore) SessionClosed(ctx context.Context, sessionID string) error {
if err := s.base.SessionClosed(ctx, sessionID); err != nil {
return err
}
if s.onSessionClosed != nil {
s.onSessionClosed(sessionID)
}
return nil
}