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(core): Add replicationMode for ctx and getRepository #2746

Conversation

monrostar
Copy link
Contributor

Description

This PR includes improvements for connecting to the database if you are using multiple replicas and when you need to connect to Master without using TransactionManager

Breaking changes

  • No

@michaelbromley
Copy link
Member

Hi,

Thanks, this looks good. Can you make a suggestion for some documentation on this feature? At least as doc blocks on the new method/property.

@monrostar
Copy link
Contributor Author

Hi,

Thanks, this looks good. Can you make a suggestion for some documentation on this feature? At least as doc blocks on the new method/property.

Of course, I will. I can do it tomorrow

): Repository<Entity>;
getRepository<Entity extends ObjectLiteral>(
ctxOrTarget: RequestContext | ObjectType<Entity> | EntitySchema<Entity> | string | undefined,
maybeTarget?: ObjectType<Entity> | EntitySchema<Entity> | string,
replicationMode?: ReplicationMode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it's probably better to use an object instead of a strict arg

Copy link
Member

Choose a reason for hiding this comment

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

For future extensibility?

Copy link
Contributor Author

@monrostar monrostar Apr 4, 2024

Choose a reason for hiding this comment

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

yes. For example, there may be several databases in the future

Copy link

vercel bot commented Aug 11, 2024

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

Name Status Preview Updated (UTC)
docs ❌ Failed (Inspect) Aug 11, 2024 10:58am

@monrostar
Copy link
Contributor Author

@michaelbromley

I've added documentation to this code. We actively use the master connection in index update and other methods, such as email-send or SMS-send, to ensure that at the time of processing, workers take the most up-to-date data if this data was updated less than a second ago.

I'd still like to work on the Queue interface. We have identified a problem that some tasks can be executed before the transaction is completed on the server.
I can make an issue or prepare a PR with an extended interface to be able to extend the functions of task registration depending on the service that is used

@michaelbromley michaelbromley merged commit 60cdae3 into vendure-ecommerce:minor Aug 13, 2024
11 of 12 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
@michaelbromley
Copy link
Member

Hey, thanks for finding the time to complete this PR!

It now strikes me that we should have a page in our developer guide > advanced topics covering how to run Vendure with a replicated DB setup, so that others are aware of the considerations and potential pitfalls to this arrangement. Would you have time/interest in writing anything on this topic? Even just a list of bullet points that I can then flesh out.

I can make an issue or prepare a PR with an extended interface to be able to extend the functions of task registration depending on the service that is used

Yeah an issue outlining the problem & proposed solution would be a good start :+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants