Add PineconeDataPlaneClient Interface #76
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, we have two flavors of classes for dealing with
blocking
andfuture
behavior for gRPC data plane calls:PineconeBlockingDataPlaneClient
PineconeFutureDataPlaneClient
Ultimately, both of these classes conform to the same interface for wrapping data plane calls, and both classes have internal logic for validating the arguments passed to these requests that's duplicated across both classes:
Solution
Unify the two data plane wrapper classes with a
PineconeDataPlaneClient
interface.This interface has default methods for dealing with validation steps for each core dataplane operation:
upsert
query
fetch
update
delete
describeIndexStats
The interface also has stubs for the various overloaded functions that are used to improve the development experience for consumers since Java 8 doesn't support optional arguments. Keeping this contract in an interface allows us to define the expected shape in one place, and avoid needing to validate consistency across the two files.
The interface takes in 6 generic types to represent the return types for each "group" of data plane operations. The reason for this is
PineconeBlockingDataPlaneClient
andPineconeFutureDataPlaneClient
have different return types where the blocking class returns the response objects directly, and the future class returnsListenableFuture<T>
. Using generics, this gives us the flexibility to define our own return types for each group of operations:upsert
-T
query
-U
fetch
-V
update
-W
delete
-X
describeIndexStats
-Z
Type of Change
Test Plan
The classes remain the same, so integration tests and builds should pass as normal.