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

Add utility for resetting consumer Django state before each event #270

Open
timmc-edx opened this issue Sep 20, 2023 · 1 comment
Open

Comments

@timmc-edx
Copy link
Contributor

Both event-bus-kafka and event-bus-redis call a _reconnect_to_db_if_needed function before processing each event. This ensures that the database connection is in a good state before work begins. In a normal request-driven environment, this would automatically be handled by Django.

We're also adding a call to clear the request cache in event-bus-kafka, in case there are signal receivers that would normally be called in a request context and that rely on the request cache.

openedx-events should probably host a utility function that can be called from each implementation's consume loop in order to generically reset the application state for each new event that needs to be processed. (Also see #236 for the possibility of more general request-like resetting.)

@robrap
Copy link
Contributor

robrap commented Sep 20, 2023

Just making it extra clear that "clear the request cache" still needs to be added to event-bus-redis, and this ticket would be a great way to get this change and future changes as well. Of course, with this change, someone would also want to retrofit event-bus-kafka to use the shared implementation.

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

No branches or pull requests

2 participants