Tools lists the underlying toolset's tools and tracks listing-failure streaks so callers can de-duplicate warnings via ShouldReportListFailure(). A successful listing clears the streak so a future failure is reported as fresh.
(ctx context.Context)
| 194 | // A successful listing clears the streak so a future failure is reported as |
| 195 | // fresh. |
| 196 | func (s *StartableToolSet) Tools(ctx context.Context) ([]Tool, error) { |
| 197 | ta, err := s.ToolSet.Tools(ctx) |
| 198 | |
| 199 | s.mu.Lock() |
| 200 | defer s.mu.Unlock() |
| 201 | if err != nil { |
| 202 | s.listStreak.fail() |
| 203 | return nil, err |
| 204 | } |
| 205 | |
| 206 | s.listStreak.reset() |
| 207 | return ta, nil |
| 208 | } |
| 209 | |
| 210 | // Stop stops the toolset if it implements Startable and resets |
| 211 | // the started flag so that a subsequent Start will re-initialize. |