mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-06-11 00:34:54 +02:00
385d1ab141
Add Redis-backed response caching for read-heavy API endpoints (nodes, advertisements, messages, channels, dashboard, profiles) with configurable TTL, key prefix isolation, and graceful fallback when Redis is unavailable. New files: - common/redis.py: CacheBackend, NullCache, RedisCacheBackend - api/cache.py: @cached decorator, sorted_query_string helper - tests/test_api/test_cache.py: 23 unit tests Changes: - pyproject.toml: add redis[hiredis] dependency - common/config.py: 8 Redis settings on APISettings - api/cli.py: Redis Click options + startup banner - api/app.py: Redis lifespan init/cleanup, X-Cache middleware, health check - 6 route files: apply @cached decorator to list endpoints - docker-compose.yml: Redis service (cache profile), env vars - docker-compose.dev.yml: Redis port exposure - .env.example, README.md, AGENTS.md, docs/upgrading.md: documentation Redis is disabled by default (REDIS_ENABLED=false). Enable with --profile cache and REDIS_ENABLED=true.
179 lines
3.8 KiB
TOML
179 lines
3.8 KiB
TOML
[build-system]
|
|
requires = ["setuptools>=68.0", "wheel"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
name = "meshcore-hub"
|
|
version = "0.0.0"
|
|
description = "Python monorepo for managing and orchestrating MeshCore mesh networks"
|
|
readme = "README.md"
|
|
license = {text = "GPL-3.0-or-later"}
|
|
requires-python = ">=3.14"
|
|
authors = [
|
|
{name = "MeshCore Hub Contributors"}
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 3 - Alpha",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
"Operating System :: OS Independent",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.14",
|
|
"Topic :: Communications",
|
|
"Topic :: System :: Networking",
|
|
]
|
|
keywords = ["meshcore", "mesh", "network", "mqtt", "lora"]
|
|
dependencies = [
|
|
"click>=8.1.0",
|
|
"pydantic>=2.0.0",
|
|
"pydantic-settings>=2.0.0",
|
|
"python-dotenv>=1.0.0",
|
|
"sqlalchemy>=2.0.0",
|
|
"alembic>=1.12.0",
|
|
"fastapi>=0.100.0",
|
|
"starlette>=0.40.0,<1.0.0",
|
|
"uvicorn[standard]>=0.23.0",
|
|
"paho-mqtt>=2.0.0",
|
|
"jinja2>=3.1.0",
|
|
"python-multipart>=0.0.6",
|
|
"httpx>=0.25.0",
|
|
"authlib>=1.3.0",
|
|
"itsdangerous>=2.0.0",
|
|
"aiosqlite>=0.19.0",
|
|
"pyyaml>=6.0.0",
|
|
"python-frontmatter>=1.0.0",
|
|
"markdown>=3.5.0",
|
|
"prometheus-client>=0.20.0",
|
|
"meshcoredecoder>=0.3.2",
|
|
"redis[hiredis]>=5.0.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=7.4.0",
|
|
"pytest-asyncio>=0.21.0",
|
|
"pytest-cov>=4.1.0",
|
|
"black>=23.0.0",
|
|
"flake8>=6.1.0",
|
|
"mypy>=1.5.0",
|
|
"pre-commit>=3.4.0",
|
|
"beautifulsoup4>=4.12.0",
|
|
"types-paho-mqtt>=1.6.0",
|
|
"types-PyYAML>=6.0.0",
|
|
]
|
|
postgres = [
|
|
"asyncpg>=0.28.0",
|
|
"psycopg2-binary>=2.9.0",
|
|
]
|
|
|
|
[project.scripts]
|
|
meshcore-hub = "meshcore_hub.__main__:main"
|
|
|
|
[project.urls]
|
|
Homepage = "https://github.com/ipnet-mesh/meshcore-hub"
|
|
Documentation = "https://github.com/ipnet-mesh/meshcore-hub#readme"
|
|
Repository = "https://github.com/ipnet-mesh/meshcore-hub"
|
|
Issues = "https://github.com/ipnet-mesh/meshcore-hub/issues"
|
|
|
|
[tool.setuptools.packages.find]
|
|
where = ["src"]
|
|
|
|
[tool.setuptools.package-data]
|
|
meshcore_hub = ["py.typed"]
|
|
"meshcore_hub.web" = ["templates/**/*", "static/**/*"]
|
|
"meshcore_hub.api" = ["templates/**/*"]
|
|
|
|
[tool.black]
|
|
line-length = 88
|
|
target-version = ["py313"]
|
|
include = '\.pyi?$'
|
|
extend-exclude = '''
|
|
/(
|
|
\.eggs
|
|
| \.git
|
|
| \.hg
|
|
| \.mypy_cache
|
|
| \.tox
|
|
| \.venv
|
|
| _build
|
|
| buck-out
|
|
| build
|
|
| dist
|
|
| alembic/versions
|
|
)/
|
|
'''
|
|
|
|
[tool.mypy]
|
|
python_version = "3.14"
|
|
warn_return_any = true
|
|
warn_unused_ignores = true
|
|
disallow_untyped_defs = true
|
|
disallow_incomplete_defs = true
|
|
check_untyped_defs = true
|
|
strict_optional = true
|
|
plugins = ["pydantic.mypy"]
|
|
|
|
[[tool.mypy.overrides]]
|
|
module = [
|
|
"paho.*",
|
|
"uvicorn.*",
|
|
"alembic.*",
|
|
"frontmatter.*",
|
|
"markdown.*",
|
|
"prometheus_client.*",
|
|
"meshcoredecoder.*",
|
|
"authlib.*",
|
|
"redis.*",
|
|
]
|
|
ignore_missing_imports = true
|
|
|
|
[[tool.mypy.overrides]]
|
|
module = [
|
|
"tests.*",
|
|
"conftest",
|
|
]
|
|
disallow_untyped_defs = false
|
|
disallow_incomplete_defs = false
|
|
|
|
[[tool.mypy.overrides]]
|
|
module = [
|
|
"alembic.env",
|
|
"alembic.versions.*",
|
|
]
|
|
ignore_errors = true
|
|
|
|
[tool.pytest.ini_options]
|
|
minversion = "7.0"
|
|
asyncio_mode = "auto"
|
|
testpaths = ["tests"]
|
|
python_files = ["test_*.py"]
|
|
python_classes = ["Test*"]
|
|
python_functions = ["test_*"]
|
|
addopts = [
|
|
"-ra",
|
|
"-q",
|
|
"--strict-markers",
|
|
"--cov=meshcore_hub",
|
|
"--cov-report=term-missing",
|
|
]
|
|
filterwarnings = [
|
|
"ignore::DeprecationWarning",
|
|
]
|
|
|
|
[tool.coverage.run]
|
|
source = ["src/meshcore_hub"]
|
|
branch = true
|
|
omit = [
|
|
"*/tests/*",
|
|
"*/__pycache__/*",
|
|
]
|
|
|
|
[tool.coverage.report]
|
|
exclude_lines = [
|
|
"pragma: no cover",
|
|
"def __repr__",
|
|
"raise NotImplementedError",
|
|
"if TYPE_CHECKING:",
|
|
"if __name__ == .__main__.:",
|
|
]
|