mirror of
https://github.com/tiennm99/openai-status-bot.git
synced 2026-10-19 00:15:15 +00:00
refactor(store): replace Redis with MongoDB datastore
Swap the Redis datastore for MongoDB via mongo-driver v2. New internal/mongostore mirrors the old redisstore type/constant names so consumers change only the import qualifier; document model collapses the multi-key subscriber/settings and per-event delivery sets into single-doc operations and a TTL-indexed delivery collection. Config now requires MONGODB_URI (Atlas) with MONGODB_DATABASE selecting dev vs prod on one cluster; REDIS_URL removed. Compose files run bot-only against Atlas. Default tests stay Docker-free (poller/bot use fakes, mongostore unit tests are pure-logic); a gated //go:build integration suite covers the real backend via testcontainers.
This commit is contained in:
1 parent
90eb8fa819
commit
546e6fcde2
40 files changed
+1704
-958
No files matched your search
+12
-14
@@ -3,7 +3,7 @@
|
||||
## Prerequisites
|
||||
|
||||
- Go 1.24+
|
||||
- Redis 7+
|
||||
- MongoDB Atlas cluster (managed, no local MongoDB service required)
|
||||
- Telegram bot token from BotFather
|
||||
|
||||
## Local Docker Run
|
||||
@@ -11,40 +11,38 @@
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# REDIS_URL is overridden to redis://redis:6379/0 by docker compose
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# docker compose sets MONGODB_DATABASE=openai_status_bot_dev for local development
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
The bundled Redis service is for local development and binds to `127.0.0.1:6379` on the host.
|
||||
The Docker Compose service connects to MongoDB Atlas; there is no bundled local MongoDB. Ensure `MONGODB_URI` is set in `.env`.
|
||||
|
||||
## Bot-Only Docker Run
|
||||
|
||||
Use this when Redis is hosted outside Docker Compose:
|
||||
Use this for production deployment:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# set REDIS_URL to the external Redis URL, not localhost
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# MONGODB_DATABASE defaults to openai_status_bot (production)
|
||||
docker compose -f docker-compose.bot.yml up -d --build
|
||||
```
|
||||
|
||||
## Local Go Run
|
||||
|
||||
Start Redis:
|
||||
|
||||
```bash
|
||||
docker run --rm -p 127.0.0.1:6379:6379 redis:7-alpine
|
||||
```
|
||||
|
||||
Run bot:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# export TELEGRAM_BOT_TOKEN or source .env with your shell workflow
|
||||
# REDIS_URL defaults to redis://localhost:6379/0
|
||||
# MONGODB_DATABASE defaults to openai_status_bot
|
||||
go run ./cmd/openai-status-bot
|
||||
```
|
||||
|
||||
MongoDB Atlas connection is required; there is no local MongoDB fallback.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user