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

feat!: add region parameter #183

Merged
merged 3 commits into from
Jul 3, 2024
Merged

Conversation

eduardoboucas
Copy link
Member

Which problem is this pull request solving?

In #158, we've added experimental support for configurable regions to deploy-scoped stores (i.e. stores created with getDeployStore()). It works as follows:

  • For API calls (i.e. when using an API token), you can use getDeployStore({ experimentalRegion: "auto" }) to instruct the API to choose the same region as the one configured for functions
    • If this parameter is not supplied, the Blobs client will not send any region parameter to the API, which means the default region will be used
  • For edge calls (i.e. when using a token from a serverless function or an edge function), you can use getDeployStore({ experimentalRegion: "context" }) to instruct the CDN to choose the region defined in the environment
    • If a region is not defined in the environment, an error will be thrown
    • This should not happen, since we're populating the environment with a region in all contexts (serverless functions, edge functions, and the CLI)

This PR introduces the following changes:

  • The experimentalRegion parameter is removed
  • A new region parameter is added to the getDeployStore method, which takes the name of a region
  • For API calls, a region is now always sent to the API
    • If a region has been specified via the region parameter, that will be used
    • If not, the client will use auto
  • For edge calls, a region is now always sent to the CDN
    • If a region has been specified via the region parameter, that will be used
    • If not, the region specified in the context will be used, if one is set
    • If not, an error will be thrown

Technically, this is a breaking change because getDeployStore() now selects the functions region by default instead of the default region, accessing the same store using different versions of the Blobs client might generate different reasons, since they may be pointing to different regions.

Should you want to update your Blobs client but keep accessing a deploy-scoped store that has been created with an older version, you can use getDeployStore({ region: "us-east-2" }) to ensure you're using the right region.

@eduardoboucas eduardoboucas requested a review from a team as a code owner July 3, 2024 12:27
Copy link

netlify bot commented Jul 3, 2024

Deploy Preview for blobs-js ready!

Name Link
🔨 Latest commit 234c280
🔍 Latest deploy log https://app.netlify.com/sites/blobs-js/deploys/6685452122a620000894e837
😎 Deploy Preview https://deploy-preview-183--blobs-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jul 3, 2024
@eduardoboucas eduardoboucas merged commit 03187bb into main Jul 3, 2024
9 checks passed
@eduardoboucas eduardoboucas deleted the feat/add-region-parameter branch July 3, 2024 13:49
serhalp added a commit to serhalp/unstorage that referenced this pull request Sep 15, 2024
The peer dependency only specifies support for v6 and v7, but v8 works
just fine.

This adds v8 to the peer dependencies, bumps the dev dep to v8, updates
the tests (there's a new requirement that's specific to unusual use
cases like unstorage's tests, which are run outside of the Netlify
platform and the Netlify CLI), and adjust the driver types to ensure
compatibility with all supported versions.

See netlify/blobs#183.

I believe @netlify/blobs@8 will error in local dev when using
netlify-cli before 17.21.1. This doesn't seem like unstorage's problem
though, so I didn't do anything about that here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants