Library Search
结果页服务注册发现与健康检查
在 技术栈 中找到 8 个匹配结果。
技术栈
技术栈
8 个 HashiCorp Consul # Consul 服务注册发现与健康检查
## 目标
使用 Python consul 库注册服务、查询服务、配置健康检查。
## 环境准备
```bash
pip install python-consul
# 确保 Consul 运行中
docker run -d --name consul -p 8500:8500 consul:latest agent -dev -client=0.0… 2% Nacos | 模式 | 适用场景 | 取舍 |
|------|----------|------|
| **AP** | 一般微服务注册发现 | 网络分区时各节点可独立工作,恢复后自动合并 |
| **CP** | 金融/支付等强一致场景 | 网络分区时少数节点拒绝写入 |
> 这是 Nacos 相比 Eureka(纯 AP)和 ZooKeeper(纯 CP)的核心优势。
### 2.3 健康检查机制… 2% etcd ```bash
# 节点1
etcd --name infra0 \
--initial-advertise-peer-urls http://10.0.1.10:2380 \
--listen-peer-urls http://10.0.1.10:2380 \
--listen-client-urls http://10.0.1.10:2379,http://127.0.0.1:23… 2% Spring Boot @Modifying
@Query("UPDATE User u SET u.email = :email WHERE u.id = :id")
int updateEmail(@Param("id") Long id, @Param("email") String email);
}
```
## 第四章:Actuator 监控
### 4.1 启用端点
```proper… 1% FastAPI @app.get("/public/health")
async def health_check():
"""公开接口 —— 无需认证"""
return {"status": "healthy", "users_count": len(fake_users_db)}
```
## 测试
```bash
# 1. 获取 Token(alice / secret123)
cur… 1% GraphQL // ── Resolver ──
const resolvers = {
Query: {
books: () => books,
book: (_, { id }) => books.find(b => b.id === id),
authors: () => authors,
author: (_, { id }) => authors.find(a =>… 1% Spring Cloud 参考文献:
[
{
"url": "https://docs.spring.io/spring-cloud/docs/current/reference/html/",
"type": "web",
"year": 2024,
"title": "Spring Cloud Reference",
"authors": [
"Spring Te… 1% Firebase Firestore 参考文献:
[
{
"type": "web",
"year": 2024,
"title": "Firebase Firestore 官方文档",
"authors": [
"Google LLC"
]
},
{
"type": "book",
"year": 2020,
"title": "Full-Sta… 1%