Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ pip install allgreen[fastapi]

### 1. Create your health checks

Create an `allgreen.py` file in your project root:
Create an `allgreen_config.py` file in your project root:

```python
# allgreen.py
# allgreen_config.py

@check("Database connection is healthy")
def database_check():
Expand Down Expand Up @@ -248,7 +248,7 @@ app = Flask(__name__)
mount_healthcheck(
app,
app_name="My Flask API",
config_path="config/allgreen.py",
config_path="config/allgreen_config.py",
environment="production"
)

Expand Down Expand Up @@ -306,8 +306,8 @@ async def health(request: Request):

Check out the `examples/` directory for complete working examples:

- **[`examples/allgreen.py`](examples/allgreen.py)** - Basic health checks configuration
- **[`examples/advanced_allgreen.py`](examples/advanced_allgreen.py)** - Advanced features (timeouts, rate limiting)
- **[`examples/allgreen_config.py`](examples/allgreen_config.py)** - Basic health checks configuration
- **[`examples/advanced_allgreen_config.py`](examples/advanced_allgreen_config.py)** - Advanced features (timeouts, rate limiting)
- **[`examples/core_only_example.py`](examples/core_only_example.py)** - Core-only usage (no web dependencies)
- **[`examples/flask_example.py`](examples/flask_example.py)** - Flask integration example
- **[`examples/django_example.py`](examples/django_example.py)** - Django integration example
Expand All @@ -317,8 +317,8 @@ Check out the `examples/` directory for complete working examples:

Allgreen automatically looks for configuration files in these locations:

1. `allgreen.py` (project root)
2. `config/allgreen.py`
1. `allgreen_config.py` (project root)
2. `config/allgreen_config.py`
3. Custom path via `config_path` parameter

## 🎛️ Environment Variables
Expand Down
10 changes: 5 additions & 5 deletions allgreen/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ def __init__(self, config_path: str | None = None):
self._loaded_path: str | None = None

def find_config_file(self) -> str | None:
"""Find allgreen.py configuration file in standard locations."""
"""Find allgreen_config.py configuration file in standard locations."""
if self.config_path:
if os.path.exists(self.config_path):
return os.path.abspath(self.config_path)
raise FileNotFoundError(f"Config file not found: {self.config_path}")

# Standard locations to check
possible_paths = [
"allgreen.py",
"config/allgreen.py",
os.path.join(os.getcwd(), "allgreen.py"),
os.path.join(os.getcwd(), "config", "allgreen.py"),
"allgreen_config.py",
"config/allgreen_config.py",
os.path.join(os.getcwd(), "allgreen_config.py"),
os.path.join(os.getcwd(), "config", "allgreen_config.py"),
]

for path in possible_paths:
Expand Down
4 changes: 2 additions & 2 deletions allgreen/integrations/django_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'allgreen',
]

2. Create health checks in allgreen.py file in your project root
2. Create health checks in allgreen_config.py file in your project root

Usage:
# In urls.py
Expand Down Expand Up @@ -85,7 +85,7 @@ def healthcheck_view(
Args:
request: Django HTTP request
app_name: Application name to display
config_path: Path to allgreen.py config file
config_path: Path to allgreen_config.py config file
environment: Environment name (defaults to 'development')
"""

Expand Down
2 changes: 1 addition & 1 deletion allgreen/integrations/fastapi_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def create_router(

Args:
app_name: Application name to display
config_path: Path to allgreen.py config file
config_path: Path to allgreen_config.py config file
environment: Environment name
prefix: URL prefix for routes (use with app.include_router(router, prefix="/..."))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Advanced allgreen.py configuration demonstrating rate limiting and timeouts
# Advanced allgreen_config.py configuration demonstrating rate limiting and timeouts

@check("Basic health check")
def basic_check():
Expand Down
2 changes: 1 addition & 1 deletion examples/allgreen.py → examples/allgreen_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sample allgreen.py configuration file
# Sample allgreen_config.py configuration file
# This demonstrates various types of health checks

@check("Basic truth check")
Expand Down
2 changes: 1 addition & 1 deletion examples/core_only_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run_health_checks():
"""Run all health checks and return results."""
# Load additional checks from config file (if available)
try:
load_config("examples/allgreen.py", "development")
load_config("examples/allgreen_config.py", "development")
except Exception:
print("💡 No config file found, using inline checks only")

Expand Down
2 changes: 1 addition & 1 deletion examples/django_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def index(request):
print("🚀 Django + Allgreen Example")
print("📋 Health checks: http://localhost:8000/healthcheck/")
print("🔧 JSON API: http://localhost:8000/healthcheck/?format=json")
print("💡 Using config: examples/allgreen.py")
print("💡 Using config: examples/allgreen_config.py")
print()

# Run Django dev server
Expand Down
6 changes: 3 additions & 3 deletions examples/fastapi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def index():
# Method 1: Mount the health check router
health_router = create_router(
app_name="FastAPI Example App",
config_path="examples/allgreen.py",
config_path="examples/allgreen_config.py",
environment="development"
)
app.include_router(health_router)
Expand All @@ -52,7 +52,7 @@ async def health_check(request: Request):
return await healthcheck_endpoint(
request,
app_name="FastAPI Direct Endpoint",
config_path="examples/allgreen.py",
config_path="examples/allgreen_config.py",
environment="development"
)

Expand All @@ -61,7 +61,7 @@ async def health_check(request: Request):
print("📋 Health checks: http://localhost:8000/healthcheck")
print("🔧 JSON API: http://localhost:8000/healthcheck.json")
print("📚 OpenAPI docs: http://localhost:8000/docs")
print("💡 Using config: examples/allgood.py")
print("💡 Using config: examples/allgreen_config.py")
print()

# Run with uvicorn
Expand Down
2 changes: 1 addition & 1 deletion examples/flask_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def index():
mount_healthcheck(
app,
app_name="Flask Example App",
config_path="examples/allgreen.py",
config_path="examples/allgreen_config.py",
environment="development"
)

Expand Down
4 changes: 2 additions & 2 deletions test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

if __name__ == "__main__":
print("🚀 Starting allgreen health check server...")
print("📋 Config: examples/allgreen.py")
print("📋 Config: examples/allgreen_config.py")
print("🌐 URL: http://127.0.0.1:5000/healthcheck")
print("🔧 Environment: development")
print()

run_standalone(
app_name="Allgreen Test Server",
config_path="examples/allgreen.py",
config_path="examples/allgreen_config.py",
environment="development",
host="127.0.0.1",
port=5000,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def test_find_config_file():
# Test with a temporary config file
with tempfile.TemporaryDirectory() as tmpdir:
config_path = os.path.join(tmpdir, "allgreen.py")
config_path = os.path.join(tmpdir, "allgreen_config.py")
with open(config_path, 'w') as f:
f.write('# test config')

Expand All @@ -17,7 +17,7 @@ def test_find_config_file():
os.chdir(tmpdir)
found_path = find_config()
assert found_path is not None
assert found_path.endswith("allgreen.py")
assert found_path.endswith("allgreen_config.py")
finally:
os.chdir(original_cwd)

Expand Down Expand Up @@ -63,7 +63,7 @@ def math_check():


def test_load_nonexistent_config():
success = load_config("/nonexistent/path/allgreen.py")
success = load_config("/nonexistent/path/allgreen_config.py")
assert not success, "Should fail to load nonexistent config"


Expand Down