Init concurrently initializes all of its [ServerProxier]s.
(ctx context.Context)
| 50 | |
| 51 | // Init concurrently initializes all of its [ServerProxier]s. |
| 52 | func (s *ServerProxyManager) Init(ctx context.Context) (outErr error) { |
| 53 | ctx, span := s.tracer.Start(ctx, "ServerProxyManager.Init") |
| 54 | defer tracing.EndSpanErr(span, &outErr) |
| 55 | |
| 56 | cg := utils.NewConcurrentGroup() |
| 57 | for _, proxy := range s.proxiers { |
| 58 | cg.Go(func() error { |
| 59 | return proxy.Init(ctx) |
| 60 | }) |
| 61 | } |
| 62 | |
| 63 | // Wait for all servers to initialize and load their tools. |
| 64 | err := cg.Wait() |
| 65 | |
| 66 | // Aggregate all proxiers' tools. |
| 67 | for _, proxy := range s.proxiers { |
| 68 | s.addTools(proxy.ListTools()) |
| 69 | } |
| 70 | |
| 71 | return err |
| 72 | } |
| 73 | |
| 74 | func (s *ServerProxyManager) GetTool(name string) *Tool { |
| 75 | s.toolsMu.RLock() |