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

Fix concurrency safe due to shared atI18n object #27

Closed

Conversation

tung491
Copy link

@tung491 tung491 commented Feb 5, 2023

In terms of the #21 issue, the middleware is not concurrency safe due to using atI18n variable at global scope. It would be critical to run in the production which handle many concurrency requests. So I propose to fix it by storing atI18n variable in gin.Context. However, the change would be made a break change in the signatures of GetMessage and MustGetMessage function

@tung491 tung491 changed the title Fix/shared i18n variable Fix concurrency safe due to shared atI18n object Feb 5, 2023
return func(context *gin.Context) {
context.Set("i18n", atI18n)
atI18n.setCurrentContext(context)
Copy link
Contributor

Choose a reason for hiding this comment

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

@tung491 You should remove this line of code, because of it is no longer available.

return func(context *gin.Context) {
context.Set("i18n", atI18n)
Copy link
Contributor

Choose a reason for hiding this comment

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

Because the length of the data in context is limited, in my opinion. We shouldn't do this.

@jonesyang12 jonesyang12 mentioned this pull request Jun 8, 2023
@appleboy appleboy closed this in b8f7fd2 Jul 27, 2023
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