http: api 接口层,接受及返回 http 请求,调用 pub 进行业务逻辑处理
pub:grpc client,暴露 grpc 接口,具体逻辑实现在 server
server:接受对应请求进行处理,调用 db 等操作
- vientiane/http/main.go:http 服务入口
- vientiane/http/router:路由管理
- vientiane/http/handle:调用后端服务处理器
- vientiane/main.go: 后端服务入口
- dao:数据库接口层
- service:业务逻辑处理
- utils:通用工具
接口返回的数据标准格式
{
"code": 200,
"message": "ok",
"data": {
"res": [],
"offset": 20,
"count": 100
}
}
下载 zookeeper、kafka 镜像
docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka
启动 zookeeper、kafka
docker run -d --name zookeeper -p 2181:2181 -e ALLOW_ANONYMOUS_LOGIN=yes bitnami/zookeeper
docker run -d --name kafka -p 9092:9092 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=localhost:2181 \
-e KAFKA_CREATE_TOPICS=test_topic:1:1 \
bitnami/kafka
ps:使用 docker inspect 查看 zookeeper IPAddress
创建本地 prometheus 配置文件
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9999']
创建 prometheus 容器; 使用 -v 参数将本地的 prometheus.yaml 文件挂载到容器内部的 /etc/prometheus/prometheus.yaml 路径。这样,Prometheus 将使用该配置文件进行配置
docker run -d -p 9999:9999 \
-v /Users/suchenghao/workspace/mself/vientiane/server/conf/prometheus.yaml:/etc/prometheus/prometheus.yaml \
--name prometheus \
prom/prometheus