Skip to content

Implement Vectorize GA binding changes#2443

Merged
mikea merged 1 commit intocloudflare:mainfrom
ndisidore:nathan/vectorize-ga
Jul 26, 2024
Merged

Implement Vectorize GA binding changes#2443
mikea merged 1 commit intocloudflare:mainfrom
ndisidore:nathan/vectorize-ga

Conversation

@ndisidore
Copy link
Copy Markdown
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 requested review from a team as code owners July 25, 2024 16:21
@ndisidore ndisidore force-pushed the nathan/vectorize-ga branch 2 times, most recently from 0f0cdfb to f2e3127 Compare July 25, 2024 20:02
@ndisidore ndisidore force-pushed the nathan/vectorize-ga branch from f2e3127 to df1a145 Compare July 25, 2024 22:29

class VectorizeIndexImpl implements VectorizeIndex {
/*
* The Vectorize beta VectorizeIndex shares the same methods, so to keep things simple, they share one implementation.
Copy link
Copy Markdown
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 force-pushed the nathan/vectorize-ga branch from df1a145 to da47902 Compare July 25, 2024 22:35
@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
Copy Markdown
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.

@ndisidore ndisidore force-pushed the nathan/vectorize-ga branch from da47902 to df5356e Compare July 26, 2024 14:21
return new VectorizeIndexImpl(
env.fetcher,
env.indexId,
env.indexVersion ?? "v1"
Copy link
Copy Markdown
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
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