-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[spruce] Fix index targeting via VectorOperationsProvider (#179)
## Problem Back when I implemented the new `IndexHostSingleton` there was a bug introduced in `VectorOperationsProvider`. Since we're assigning to `this.config.indeHostUrl` inside `provide()`, it's updating the `config` reference meaning once you initially target an index, it holds onto that URL and reuses for all dataplane requests, regardless of which index you're now trying to target. https://github.com/pinecone-io/pinecone-ts-client/blob/41389d4a101cea996d17848c49f22d2d3991b34a/src/data/vectorOperationsProvider.ts#L39 ## Solution - Remove the `IndexConfiguration` type. Originally I had added `IndexConfiguration` as an extension of `PineconeConfiguration`, but this feels unnecessary as it was only used within `VectorOperationsProvider`, and it proved to be more confusing than anything. - Add `indexHostUrl` as a private field to `VectorOperationsProvider`. This field will be set immediately if an `indexHostUrl` has been passed as part of the `Index` constructor, otherwise it's resolved via the `IndexHostSingleton`. - `namespace` targeting in the `Index` class was not passing `indexHostUrl` as we'd expect, updated this will I was making changes. ## Type of Change - [X] Bug fix (non-breaking change which fixes an issue) ## Test Plan You'll need multiple indexes so you can chain calls to one or the other to validate targeting. ``` $ npm run repl $ await init $ await client.index('index-1').describeIndexStats() // verify the correct stats for index-1 are returned $ await client.index('index-2').describeIndexStats() // verify the correct stats for index-2 are returned ``` Previously, once you'd targeted an index all subsequent dataplane calls would be made to the original host URL.
- Loading branch information
1 parent
41389d4
commit f7d49d8
Showing
4 changed files
with
21 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters