-
Notifications
You must be signed in to change notification settings - Fork 17
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
docs: add rfc for storage architecture #1290
base: main
Are you sure you want to change the base?
Conversation
let say if we have an API that do update account, after success updating, we need to query the feature table to get number of features then return both value to client. Would you call account storage to update account then call feature storage or would you do it in one storage? |
Thank you for your comment. Is this question about how to maintain consistency when multiple storages need to be updated in one request? |
editor *eventproto.Editor, | ||
email, organizationID string, | ||
) error { | ||
// No DB operations such as transaction processing are performed, just call Update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same question with @hvn2k1 #1290 (comment), some API will need to operate on more than one table, can you please provide more examples about how to do this transaction in API layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you everyone for your comments.
I'll certainly think of a way to do this and update the documentation, as I need to consider this case.
@kakcy yes, sometimes when an API needs to be updated, the function's behavior in a storage needs to be changed to, but what if that function is used in another API? Maybe we can just update it without affecting the other, but what if it is too hard or the changes making the function's main purpose being vague? In my old project, we also faced this question and we haven't fully answered it, but we combine both approach (use multiple storage or stay with only one depend on the situation). I may suggest this pattern:
Note: personally, I don't think there is a correct answer to this kind of question, but we can choose what is appropriate for different situations and it depends on the programmer's flexibility to make the code readable, reusable and extendable. |
@hvn2k1 @Ubisoft-potato |
|
@hvn2k1 You can maintain rollback and commit consistency by using the same storage client instance (such as mySQLClient) to create storage instances and using the same transaction instance to control transactions between different storages. |
ahh I see, it looks awesome! 💯 |
Thank you for your review! |
@cre8ivejp @kakcy The current solution proposal looks good to me. |
@cre8ivejp @kakcy this solution LGTM! 🚀 |
The main goal is to remove the mysql dependency from the API layer, and we suggest a solution by modifying the storage layer architecture. #1252