分离chassis agent;更新 readme

This commit is contained in:
BryantHe 2023-05-23 22:22:04 +08:00
parent 0d940ca58f
commit c2743784cb
6 changed files with 30 additions and 367 deletions

View File

@ -2,29 +2,41 @@
chassis <ˈʃæsi> n. 底盘,底架
仓库名寓意服务基座,基础库。
仓库名寓意服务的底盘,基础库。搭建微服务底盘是为了简化服务的创建过程,同时确保开发者遵循这套开发标准。
## 包含的特性
1. 微服务模板代码
2. 可观测 Observability
1. Metrics (Statsd + Prometheus + Grafana)
2. Logging (ELK)
3. Tracing (TODO, Maybe OpenTelemetry)
4. Error ReportingSentry)
3. 数据存储相关 utils
1. Sqlalchemy
- 连接池
- 读写分离
2. Redis
- 连接池
3. ElasticSearch
4. 服务注册和发现 (RabbitMQ)
5. 健康检查 (TODO)
6. 配置获取 (TODO)
微服务底座的目的是简化服务的创建过程,同时确保开发者拥有一套所有服务都要遵循的标准。
## 实现的功能
包含的特性
1. 错误报告
2. 日志收集
3. Metrics 数据收集
4. 配置获取
5. 数据存储设置ORM
6. 健康检查
7. 服务注册和发现
8. 模板代码
实现的功能
- 服务发现
- 服务注册和发现
- 可观测
- 传输
- 同步/异步传输
- 负载均衡
- 限流降级(消息确认+熔断)
安装方法:
`python3 -m pip install -U https://gitea.bearcatlog.com/BryantStudio/chassis.git`
## 安装方法
基础代码库:
`python3 -m pip install --trusted-host=gitea.bearcatlog.com git+https://gitea.bearcatlog.com/BryantStudio/chassis.git@main`
基础代码库依赖的服务:
`python3 -m pip install --trusted-host=gitea.bearcatlog.com git+https://gitea.bearcatlog.com/BryantStudio/chassis-agent.git@main`

View File

@ -1,7 +0,0 @@
.venv
.git
.gitignore
.dockerignore
/log/*
/tmp/*
/test/reports/*

View File

@ -1,261 +0,0 @@
{
"__inputs": [
{
"name": "Prometheus",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "4.6.2"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": null,
"links": [],
"refresh": false,
"rows": [
{
"collapse": false,
"height": "250px",
"panels": [
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${Prometheus}",
"fill": 1,
"id": 5,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"hideEmpty": false,
"hideZero": false,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "admin_service_hello",
"format": "time_series",
"hide": false,
"intervalFactor": 2,
"legendFormat": "admin_service_hello {{quantile}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Admin Service | Hello",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"transparent": false,
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${Prometheus}",
"fill": 1,
"id": 10,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "admin_service_error",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "admin_service_error {{quantile}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Admin Service | Error",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
}
],
"schemaVersion": 14,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "",
"title": "Admin Service",
"version": 5
}

View File

@ -1,32 +0,0 @@
version: "3"
services:
statsd-agent:
image: statsd/statsd:latest
restart: always
ports:
- "8125:8125/udp"
- "8126:8126"
volumes:
- "./statsd_config.js:/usr/src/app/config.js"
networks:
chassis_agent:
statsd-exporter:
image: prom/statsd-exporter:latest
hostname: "statsd-exporter"
command: "--statsd.mapping-config=/tmp/statsd_mapping.yml"
ports:
- "9102:9102"
- "9125:9125/udp"
volumes:
- "./statsd_mapping.yml:/tmp/statsd_mapping.yml"
networks:
chassis_agent:
networks:
chassis_agent:
driver: bridge
#volumes:
# chassis_agent_data:
# driver: local

View File

@ -1,8 +0,0 @@
(function () {
return {
"port": 8125,
"backends": ["./backends/repeater"],
"repeater": [{host: 'statsd-exporter', port: 9125}],
};
})();

View File

@ -1,41 +0,0 @@
mappings:
- match: "admin-service.admin-service.hello"
observer_type: summary
name: "hello"
labels:
provider: "$2"
outcome: "$3"
job: "admin-service"
summary_options:
quantiles:
- quantile: 0.99
error: 0.001
- quantile: 0.95
error: 0.01
- quantile: 0.9
error: 0.05
- quantile: 0.5
error: 0.005
max_summary_age: 30s
summary_age_buckets: 3
stream_buffer_size: 1000
- match: "admin-service.admin-service.error"
observer_type: summary
name: "error"
labels:
provider: "$2"
outcome: "$3"
job: "admin-service"
summary_options:
quantiles:
- quantile: 0.99
error: 0.001
- quantile: 0.95
error: 0.01
- quantile: 0.9
error: 0.05
- quantile: 0.5
error: 0.005
max_summary_age: 30s
summary_age_buckets: 3
stream_buffer_size: 1000