refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)

配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
This commit is contained in:
Sully
2026-05-22 13:44:50 +08:00
committed by GitHub
parent f09ae248f9
commit 53e0065e3e
298 changed files with 15247 additions and 4344 deletions

View File

@@ -0,0 +1,47 @@
---
title: Use DIALECT 2 for Query Syntax
impact: MEDIUM
impactDescription: Ensures consistent query behavior and access to modern features
tags: rqe, dialect, query, syntax
description: Use DIALECT 2 for Query Syntax
alwaysApply: true
---
## Use DIALECT 2 for Query Syntax
Use DIALECT 2 for consistent query behavior. Many Redis client libraries now default to DIALECT 2, and other dialects (1, 3, 4) are deprecated as of Redis 8.
**Correct:** Use DIALECT 2 explicitly or rely on modern client defaults.
```python
from redis import Redis
r = Redis()
# Modern redis-py (6.0+) defaults to DIALECT 2
# You can also set it explicitly
results = r.ft("idx:products").search(
"@name:laptop",
dialect=2
)
```
```
# In raw commands, specify DIALECT 2
FT.SEARCH idx:products "@name:laptop" DIALECT 2
FT.AGGREGATE idx:products "@category:{electronics}"
GROUPBY 1 @category
REDUCE COUNT 0 AS count
DIALECT 2
```
**Note:** DIALECT 2 is required for vector search queries. Most modern client libraries (redis-py 6.0+, go-redis, Lettuce) now use DIALECT 2 by default.
**Why DIALECT 2:**
- Consistent handling of special characters
- Better NULL value handling
- More predictable query parsing
- Required for vector search
Reference: [Query Dialects](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/)