diff --git a/CHANGELOG.md b/CHANGELOG.md index 4605a572..d81069dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Update the runtime's manifest usage [#417](https://github.com/hypermodeinc/modus/pull/417) - Add Modus Go SDK [#418](https://github.com/hypermodeinc/modus/pull/418) - Add Local Model Invocation Support [#421](https://github.com/hypermodeinc/modus/pull/421) +- Remove HTTP Timeout, Add Context Timeout on Collections [#422](https://github.com/hypermodeinc/modus/pull/422) ## 2024-10-02 - Version 0.12.7 diff --git a/runtime/collections/collections.go b/runtime/collections/collections.go index d93ea10b..10fb4a8e 100644 --- a/runtime/collections/collections.go +++ b/runtime/collections/collections.go @@ -15,6 +15,7 @@ import ( "fmt" "math" "sort" + "time" "github.com/hypermodeinc/modus/runtime/collections/in_mem" "github.com/hypermodeinc/modus/runtime/collections/index" @@ -101,7 +102,9 @@ func UpsertToCollection(ctx context.Context, collectionName, namespace string, k return nil, err } - executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts) + callCtx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts) if err != nil { return nil, err } @@ -190,7 +193,9 @@ func SearchCollection(ctx context.Context, collectionName string, namespaces []s texts := []string{text} - executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts) + callCtx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts) if err != nil { return nil, err } @@ -331,7 +336,9 @@ func NnClassify(ctx context.Context, collectionName, namespace, searchMethod, te texts := []string{text} - executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts) + callCtx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts) if err != nil { return nil, err } diff --git a/runtime/collections/vector.go b/runtime/collections/vector.go index 07153827..d5594ad2 100644 --- a/runtime/collections/vector.go +++ b/runtime/collections/vector.go @@ -14,6 +14,7 @@ import ( "errors" "fmt" "slices" + "time" "github.com/hypermodeinc/modus/pkg/manifest" "github.com/hypermodeinc/modus/runtime/collections/in_mem" @@ -218,7 +219,9 @@ func processTexts(ctx context.Context, col interfaces.CollectionNamespace, vecto keysBatch := keys[i:end] textsBatch := texts[i:end] - executionInfo, err := wasmhost.CallFunction(ctx, vectorIndex.GetEmbedderName(), textsBatch) + callCtx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + executionInfo, err := wasmhost.CallFunction(callCtx, vectorIndex.GetEmbedderName(), textsBatch) if err != nil { return err } diff --git a/runtime/utils/http.go b/runtime/utils/http.go index 9d0e499c..8895f922 100644 --- a/runtime/utils/http.go +++ b/runtime/utils/http.go @@ -18,9 +18,7 @@ import ( "time" ) -var httpClient = &http.Client{ - Timeout: 10 * time.Second, -} +var httpClient = &http.Client{} func HttpClient() *http.Client { return httpClient