fix(websearch): add 15s timeout for admin test search
This commit is contained in:
@@ -254,12 +254,16 @@ type WebSearchTestResult struct {
|
||||
|
||||
// TestWebSearch executes a test search using the currently configured Manager.
|
||||
// Uses Manager.TestSearch which bypasses quota tracking.
|
||||
const testSearchTimeout = 15 * time.Second
|
||||
|
||||
func TestWebSearch(ctx context.Context, query string) (*WebSearchTestResult, error) {
|
||||
mgr := getWebSearchManager()
|
||||
if mgr == nil {
|
||||
return nil, fmt.Errorf("web search: manager not initialized, save config first")
|
||||
}
|
||||
resp, providerName, err := mgr.TestSearch(ctx, websearch.SearchRequest{
|
||||
testCtx, cancel := context.WithTimeout(ctx, testSearchTimeout)
|
||||
defer cancel()
|
||||
resp, providerName, err := mgr.TestSearch(testCtx, websearch.SearchRequest{
|
||||
Query: query,
|
||||
MaxResults: webSearchDefaultMaxResults,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user