Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Vectorize GA binding changes #2443

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

ndisidore
Copy link
Contributor

@ndisidore ndisidore commented Jul 25, 2024

Sister to #2421

This creates a new shared implementation of the Vectorize type that is common to both v1 and v2, conditionally switching on the version to serve up the correct api. This allows us to keep the module name common as cloudflare-internal:vectorize-api

@ndisidore ndisidore force-pushed the nathan/vectorize-ga branch 2 times, most recently from 0f0cdfb to f2e3127 Compare July 25, 2024 20:02
@@ -16,144 +16,164 @@ enum Operation {
VECTOR_DELETE = 5,
}

class VectorizeIndexImpl implements VectorizeIndex {
/*
* The Vectorize beta VectorizeIndex shares the same methods, so to keep things simple, they share one implementation.
Copy link
Contributor Author

@ndisidore ndisidore Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we discussed @mikea and if this holds true, I think we're happy with this approach!

@ndisidore ndisidore requested a review from mikea July 25, 2024 23:25
);
public async describe(): Promise<VectorizeIndexInfo> {
const endpoint =
this.indexVersion === "v2" ? `info` : `binding/indexes/${this.indexId}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For v2, account info and index id are included in the base url of the fetcher so these endpoints just become the final path part.

return new VectorizeIndexImpl(
env.fetcher,
env.indexId,
env.indexVersion ?? "v1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures backwards compatibility, since previously built pipelines won't have these inner globals.
We default to v1 if is it not present.

@mikea mikea merged commit 32d67fd into cloudflare:main Jul 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants