Documentation
¶
Overview ¶
Package cost implements per-service cost alerting for nSelf AI and media plugins. It runs hourly (via the cron plugin or nself doctor), queries np_ai_usage.cost_usd for the last 24h, and fires a Slack webhook when any configured budget is exceeded.
Configuration env vars:
COST_ALERT_ENABLED true | false (default false) COST_BUDGET_AI_DAILY_USD float, e.g. "5.00" COST_BUDGET_MEDIA_DAILY_USD float COST_BUDGET_TOTAL_DAILY_USD float SLACK_WEBHOOK_URL https://hooks.slack.com/... SLACK_ALERT_CHANNEL #nself-alerts (informational only — embedded in message)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Budget ¶
Budget holds per-service daily spend limits in USD. A zero value means "no limit for this service".
func LoadBudgetFromEnv ¶
func LoadBudgetFromEnv() Budget
LoadBudgetFromEnv reads COST_BUDGET_* vars and returns the parsed Budget. Malformed values are ignored (budget treated as unlimited).
Click to show internal directories.
Click to hide internal directories.