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(providers): locking redis #9544

Merged
merged 28 commits into from
Oct 15, 2024
Merged

Conversation

carlos-r-l-rodrigues
Copy link
Contributor

@carlos-r-l-rodrigues carlos-r-l-rodrigues commented Oct 13, 2024

What:

  • Providers loading like modules, auto discovering models, migrations, etc
  • Locking module provider - Redis
  • Create reservation step locking to manage inventory

New util added to export a provider: ModuleProvider

export default ModuleProvider(Modules.LOCKING, {
  services,
  loaders,
})

Module providers are registered on the Module's container using the name __providers__ + provider_key_name. It is available on Module's loaders.

Postgres: #9545

⚠️ Note
In case of too many connection issue, the first thing to check (especially when running many processes) is the pool configuration in medusa-config.ts. e.g:

projectConfig: {
  databaseDriverOptions: {
      pool: {
        max: 8, // This number can also vary depending on the max connection configuration of your db or bouncer or whatever tech you are using and configuring
      },
    },
}

Convention
With the current approach to load providers, we need to validate the convention being the following one:

  • module options must has the providers keys as the option being an array and must contain
    • resolve
    • id (optional) only used if the provider does not have an identifier (@carlos-r-l-rodrigues wdyt of that, seems we need to validate something here)
    • the provider can have an identifier static property that would be used to register the provider into the module container under __providers__${identifier | id}

Copy link

changeset-bot bot commented Oct 13, 2024

⚠️ No Changeset found

Latest commit: 1525551

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 2:55pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Oct 15, 2024 2:55pm
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 2:55pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 2:55pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 2:55pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 2:55pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Oct 15, 2024 2:55pm

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

This is very exciting @carlos-r-l-rodrigues, did you already run the same tests as without it?

@carlos-r-l-rodrigues
Copy link
Contributor Author

/snapshot-this

@carlos-r-l-rodrigues
Copy link
Contributor Author

#9545
Postgres implementation

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

Left a few questions, but generally LGTM. Nice work!

@olivermrbl
Copy link
Contributor

We might need to draft up some docs on this new ModuleProvider utility

cc @shahednasser

@carlos-r-l-rodrigues carlos-r-l-rodrigues merged commit 4a03bdb into develop Oct 15, 2024
23 checks passed
kodiakhq bot pushed a commit that referenced this pull request Oct 16, 2024
Document change introduced by #9544

> Note: fine to merge now as it requires generating references, which will only happen after the next release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants