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

Lazy initialization for default Goa mux #3419

Merged
merged 2 commits into from Nov 27, 2023

Conversation

tchssk
Copy link
Member

@tchssk tchssk commented Nov 27, 2023

#3415 (comment)

  • I tried to implement it using only sync.Mutex.
    • middlewares is changed at the first call of Handle(), so it will be nil at the second call.
  • wildcards is now accessed in the mutex lock, so I reverted Use sync.Map for http.mux.wildcards #3417.

@tchssk tchssk marked this pull request as ready for review November 27, 2023 13:52
@raphael
Copy link
Member

raphael commented Nov 27, 2023

This looks great thank you! Reverting the change makes sense. It does mean that the reads are not protected against concurrent writes but that's probably OK given that writes should only occur during initialization and having a lock shared across all requests wouldn't be great from a performance point of view.

@raphael raphael merged commit 1dc06f4 into goadesign:v3 Nov 27, 2023
9 checks passed
@tchssk
Copy link
Member Author

tchssk commented Nov 28, 2023

Yes. Now Handle() is protected with a mutex, so it's impossible that concurrent access to the map inside the method.

@tchssk
Copy link
Member Author

tchssk commented Nov 28, 2023

Finally it's completed. Would you please release a new version? @raphael

@tchssk tchssk deleted the http-mux-lazy-init branch November 28, 2023 02:08
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.

None yet

2 participants