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

Making Rakismet Thread-safe #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

workmad3
Copy link

While investigating Rakismet to see how it obtained the request-related information, I noticed that a lot of the information was being stored in non-thread-safe class instance variables. Considering the larger number of people deploying onto Puma and other thread-capable servers nowadays, this seems like a large omission.

So here's a change set to store the request and responses in Thread-local variables to keep thread safety.

The tests also still pass, a large majority of them are now rewritten to use expect/allow from rspec 3.

@dwbutler
Copy link

This is a big problem. @joshfrench If this solution were brought up-to-date, would you merge it?

@joshfrench
Copy link
Owner

@dwbutler Absolutely! Sorry I dropped the ball on this before. Feel free to reopen with up-to-date code/tests/versioning.

@dwbutler
Copy link

@joshfrench I'm looking at this again. Would you be open to adding a dependency on RequestStore? It handles correctly storing a request-local variable that gets cleared at the end of each request. If not, it can be implemented in an equivalent way here.

@joshfrench
Copy link
Owner

@dwbutler Seems fine to me. If you do submit a PR please include mention of the additional setup for non-Rails apps. Thanks!

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.

3 participants