@@ -27,16 +27,6 @@ func NewMapFrom[K comparable, V any](m map[K]V) *Map[K, V] {
}
}
-// NewMapFromSeq creates a new thread-safe map from an iter.Seq2 of key-value pairs.
-func NewMapFromSeq[k comparable, v any](seq iter.Seq2[k, v]) *Map[k, v] {
- m := make(map[k]v)
- seq(func(kk k, vv v) bool {
- m[kk] = vv
- return true
- })
- return NewMapFrom(m)
-}
-
// NewLazyMap creates a new lazy-loaded map. The provided load function is
// executed in a separate goroutine to populate the map.
func NewLazyMap[K comparable, V any](load func() map[K]V) *Map[K, V] {
@@ -37,31 +37,6 @@ func TestNewMapFrom(t *testing.T) {
require.Equal(t, 1, value)
}
-func TestNewMapFromSeq(t *testing.T) {
- t.Parallel()
-
- original := map[string]int{
- "key1": 1,
- "key2": 2,
- }
- seq := func(f func(string, int) bool) {
- for k, v := range original {
- if !f(k, v) {
- break
- }
- }
- }
-
- m := NewMapFromSeq(seq)
- require.NotNil(t, m)
- require.Equal(t, original, m.inner)
- require.Equal(t, 2, m.Len())
-
- value, ok := m.Get("key2")
- require.True(t, ok)
- require.Equal(t, 2, value)
-}
-
func TestNewLazyMap(t *testing.T) {
t.Parallel()
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log/slog"
+ "maps"
"slices"
"strings"
"time"
@@ -1072,7 +1073,7 @@ func (a *agent) setupEvents() {
tools := getTools(ctx, name, c)
updateMcpTools(name, tools)
// Update the lazy map with the new tools
- a.mcpTools = csync.NewMapFromSeq(mcpTools.Seq2())
+ a.mcpTools = csync.NewMapFrom(maps.Collect(mcpTools.Seq2()))
updateMCPState(name, MCPStateConnected, nil, c, a.mcpTools.Len())
default:
continue