-
Notifications
You must be signed in to change notification settings - Fork 34
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
Implement muxing routing cache #851
base: main
Are you sure you want to change the base?
Conversation
76d9bba
to
f01d03e
Compare
import copy | ||
from abc import ABC, abstractmethod | ||
from collections import UserDict | ||
from threading import Lock, RLock |
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.
concern: I think we should only use locking primitives from the asyncio package, but I might be wrong.
https://docs.python.org/3/library/asyncio-sync.html
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.
Because we use asyncio in other places or what advantages do you see in it? According to the docs
asyncio primitives are not thread-safe, therefore they should not be used for OS thread synchronization (use threading for that);
So I think primitives from threading
are a better choice, but to be honest also not 100% sure. I can be persuaded
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.
My understanding is that we're using asyncio
everywhere, so we're single threaded (but still concurrent).
Using threading
risks locking the only thread of execution and halt the application.
I might be wrong here, but that's my understanding of how async execution environment work in general, not only in Python.
This allows us to have a parsed and in-memory representation of the routing rule engine. The intent is to reduce calls to the database. This is more expensive to maintain since we need to refresh the cache on every operation pertaining to models, endpoints, workspaces, and muxes themselves. Signed-off-by: Juan Antonio Osorio <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
fe1ccdf
to
b25a351
Compare
This allows us to have a parsed and in-memory representation of the
routing rule engine. The intent is to reduce calls to the database.
This is more expensive to maintain since we need to refresh the cache on
every operation pertaining to models, endpoints, workspaces, and muxes themselves.
Finally, this implements the interface for matchers; Currently we only have one
"catch all" matcher, but this will change in the future.
Closes #786
Signed-off-by: Juan Antonio Osorio [email protected]