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

Implement muxing routing cache #851

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

Implement muxing routing cache #851

wants to merge 4 commits into from

Conversation

JAORMX
Copy link
Contributor

@JAORMX JAORMX commented Jan 30, 2025

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]

@JAORMX JAORMX force-pushed the mux-routing-cache branch 2 times, most recently from 76d9bba to f01d03e Compare January 30, 2025 14:20
@JAORMX JAORMX requested a review from aponcedeleonch January 30, 2025 14:23
import copy
from abc import ABC, abstractmethod
from collections import UserDict
from threading import Lock, RLock
Copy link
Contributor

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

Copy link
Contributor

@aponcedeleonch aponcedeleonch Jan 31, 2025

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

Copy link
Contributor

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.

JAORMX and others added 4 commits January 31, 2025 14:18
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]>
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.

Implement "catch-all" mux matcher
3 participants