fix(config): align mongodb database names

This commit is contained in:
tiennm99 committed 2026-06-27 16:26:37 +07:00
1 parent b13a976ab0
commit 259b2dfdbd
8 files changed
+15 -15

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
TELEGRAM_BOT_TOKEN= TELEGRAM_BOT_TOKEN=
MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/ MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/
MONGODB_DATABASE=openai_status_bot MONGODB_DATABASE=openai-status-bot
POLL_INTERVAL=1m POLL_INTERVAL=1m
HTTP_TIMEOUT=10s HTTP_TIMEOUT=10s
LOG_LEVEL=info LOG_LEVEL=info
+3 -3
View File
@@ -37,7 +37,7 @@ a managed MongoDB Atlas cluster, so a reachable `MONGODB_URI` is required to
start. The development and production setups share one cluster and differ only start. The development and production setups share one cluster and differ only
by database name (`MONGODB_DATABASE`). by database name (`MONGODB_DATABASE`).
Production runtime (default Compose file; uses the `MONGODB_DATABASE` from `.env`, default `openai_status_bot`): Production runtime (default Compose file; uses the `MONGODB_DATABASE` from `.env`, default `openai-status-bot`):
```bash ```bash
cp .env.example .env cp .env.example .env
@@ -45,7 +45,7 @@ cp .env.example .env
docker compose up -d --build docker compose up -d --build
``` ```
Development runtime (targets the `development` database): Development runtime (targets the `openai-status-bot-development` database):
```bash ```bash
cp .env.example .env cp .env.example .env
@@ -66,7 +66,7 @@ go run ./cmd/openai-status-bot
|----------|---------|-------------| |----------|---------|-------------|
| `TELEGRAM_BOT_TOKEN` | required | Telegram bot token from BotFather | | `TELEGRAM_BOT_TOKEN` | required | Telegram bot token from BotFather |
| `MONGODB_URI` | required | MongoDB connection string, e.g. an Atlas `mongodb+srv://user:pass@cluster/` URI | | `MONGODB_URI` | required | MongoDB connection string, e.g. an Atlas `mongodb+srv://user:pass@cluster/` URI |
| `MONGODB_DATABASE` | `openai_status_bot` | Database name; use a separate name (e.g. `development`) to split dev and prod on one cluster | | `MONGODB_DATABASE` | `openai-status-bot` | Database name; use a separate name (e.g. `openai-status-bot-development`) to split dev and prod on one cluster |
| `POLL_INTERVAL` | `1m` | Status check interval, valid `5s`-`1h` | | `POLL_INTERVAL` | `1m` | Status check interval, valid `5s`-`1h` |
| `HTTP_TIMEOUT` | `10s` | HTTP request timeout, valid `1s`-`5m` | | `HTTP_TIMEOUT` | `10s` | HTTP request timeout, valid `1s`-`5m` |
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`/`warning`, or `error` | | `LOG_LEVEL` | `info` | `debug`, `info`, `warn`/`warning`, or `error` |
+2 -2
View File
@@ -1,11 +1,11 @@
# Development runtime: bot only, connecting to the shared Atlas cluster. # Development runtime: bot only, connecting to the shared Atlas cluster.
# There is no local datastore; set MONGODB_URI in .env. This file targets the # There is no local datastore; set MONGODB_URI in .env. This file targets the
# development database (the MONGODB_DATABASE below overrides any .env value). # openai-status-bot-development database (overrides any .env value).
services: services:
bot: bot:
build: . build: .
env_file: env_file:
- .env - .env
environment: environment:
MONGODB_DATABASE: development MONGODB_DATABASE: openai-status-bot-development
restart: unless-stopped restart: unless-stopped
+1 -1
View File
@@ -1,6 +1,6 @@
# Default production runtime: bot only, connecting to the shared Atlas cluster via .env. # Default production runtime: bot only, connecting to the shared Atlas cluster via .env.
# Uses the production database (MONGODB_DATABASE in .env, default # Uses the production database (MONGODB_DATABASE in .env, default
# openai_status_bot). There is no local datastore. # openai-status-bot). There is no local datastore.
services: services:
bot: bot:
build: . build: .
+3 -3
View File
@@ -12,7 +12,7 @@
cp .env.example .env cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env # set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string # set MONGODB_URI to your MongoDB Atlas connection string
# docker compose sets MONGODB_DATABASE=development for local development # docker compose sets MONGODB_DATABASE=openai-status-bot-development for local development
docker compose -f compose.dev.yaml up --build docker compose -f compose.dev.yaml up --build
``` ```
@@ -26,7 +26,7 @@ Use this for production deployment:
cp .env.example .env cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env # set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string # set MONGODB_URI to your MongoDB Atlas connection string
# MONGODB_DATABASE defaults to openai_status_bot (production) # MONGODB_DATABASE defaults to openai-status-bot (production)
docker compose up -d --build docker compose up -d --build
``` ```
@@ -37,7 +37,7 @@ cp .env.example .env
# set TELEGRAM_BOT_TOKEN in .env # set TELEGRAM_BOT_TOKEN in .env
# set MONGODB_URI to your MongoDB Atlas connection string # set MONGODB_URI to your MongoDB Atlas connection string
# export TELEGRAM_BOT_TOKEN or source .env with your shell workflow # export TELEGRAM_BOT_TOKEN or source .env with your shell workflow
# MONGODB_DATABASE defaults to openai_status_bot # MONGODB_DATABASE defaults to openai-status-bot
go run ./cmd/openai-status-bot go run ./cmd/openai-status-bot
``` ```
+1 -1
View File
@@ -41,7 +41,7 @@ The service uses Telegram `getUpdates` through `github.com/go-telegram/bot`, so
`telegramOffset` stores the next update ID to resume from. Because `go-telegram/bot` stores the last seen update internally and sends `lastUpdateID + 1` to Telegram, startup passes `telegramOffset - 1` as the initial framework offset when a saved offset exists. The command handler saves `update.ID + 1` after every message update, including non-command messages. `telegramOffset` stores the next update ID to resume from. Because `go-telegram/bot` stores the last seen update internally and sends `lastUpdateID + 1` to Telegram, startup passes `telegramOffset - 1` as the initial framework offset when a saved offset exists. The command handler saves `update.ID + 1` after every message update, including non-command messages.
MongoDB is configured with `MONGODB_URI` and `MONGODB_DATABASE` (default `openai_status_bot`). The OpenAI status source is fixed to `https://status.openai.com`. Docker Compose starts the bot connecting to a managed MongoDB Atlas cluster; there is no bundled local MongoDB service. MongoDB is configured with `MONGODB_URI` and `MONGODB_DATABASE` (production default `openai-status-bot`; development Compose override `openai-status-bot-development`). The OpenAI status source is fixed to `https://status.openai.com`. Docker Compose starts the bot connecting to a managed MongoDB Atlas cluster; there is no bundled local MongoDB service.
## Failure Behavior ## Failure Behavior
+1 -1
View File
@@ -22,7 +22,7 @@ const (
maxPollInterval = time.Hour maxPollInterval = time.Hour
minHTTPTimeout = time.Second minHTTPTimeout = time.Second
maxHTTPTimeout = 5 * time.Minute maxHTTPTimeout = 5 * time.Minute
defaultMongoDatabase = "openai_status_bot" defaultMongoDatabase = "openai-status-bot"
) )
func LoadFromEnv() (Config, error) { func LoadFromEnv() (Config, error) {
+3 -3
View File
@@ -32,14 +32,14 @@ func TestLoadFromEnvDefaultsAndTrimming(t *testing.T) {
func TestLoadFromEnvAcceptsCustomMongoDatabase(t *testing.T) { func TestLoadFromEnvAcceptsCustomMongoDatabase(t *testing.T) {
setMinimalEnv(t) setMinimalEnv(t)
t.Setenv("MONGODB_DATABASE", " openai_status_bot_dev ") t.Setenv("MONGODB_DATABASE", " openai-status-bot-development ")
cfg, err := LoadFromEnv() cfg, err := LoadFromEnv()
if err != nil { if err != nil {
t.Fatalf("LoadFromEnv returned error: %v", err) t.Fatalf("LoadFromEnv returned error: %v", err)
} }
if cfg.MongoDatabase != "openai_status_bot_dev" { if cfg.MongoDatabase != "openai-status-bot-development" {
t.Fatalf("MongoDatabase = %q, want openai_status_bot_dev", cfg.MongoDatabase) t.Fatalf("MongoDatabase = %q, want openai-status-bot-development", cfg.MongoDatabase)
} }
} }