-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
In api/graph.py, every function and class instantiation creates a fresh FalkorDB() connection:
def graph_exists(name: str):
db = FalkorDB(host=os.getenv('FALKORDB_HOST', 'localhost'),
port=os.getenv('FALKORDB_PORT', 6379), ...)
def get_repos() -> list[str]:
db = FalkorDB(host=os.getenv('FALKORDB_HOST', 'localhost'),
port=os.getenv('FALKORDB_PORT', 6379), ...)
class Graph:
def __init__(self, name):
self.db = FalkorDB(host=os.getenv('FALKORDB_HOST', 'localhost'),
port=os.getenv('FALKORDB_PORT', 6379), ...)This pattern is repeated for every API call, creating significant connection overhead.
Suggested Fix
Use a connection pool or module-level singleton:
from falkordb import FalkorDB
_db = FalkorDB(host=os.getenv('FALKORDB_HOST', 'localhost'),
port=os.getenv('FALKORDB_PORT', 6379))
def graph_exists(name: str):
return name in _db.list_graphs()Context
Found during code review of PR #522.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request