update README

This commit is contained in:
zhuyasen
2024-07-30 21:20:01 +08:00
parent c781fc99f7
commit a1af23f08f
12 changed files with 54 additions and 36 deletions

2
.github/RELEASE.md vendored
View File

@@ -2,4 +2,4 @@
1. Modify the returned ID type, it will affect the ID types of GetByID and List for `⓵Create web service based on sql`, which are consistent with the ID types in the database. 1. Modify the returned ID type, it will affect the ID types of GetByID and List for `⓵Create web service based on sql`, which are consistent with the ID types in the database.
> If you are using code for `⓵Create web service based on sql` before v1.8.6, do not modify the sponge version under go.mod and upgrade to v1.8.6 or above. Otherwise, the List interface will return empty data because the original `size` field has become invalid (replaced by `limit` field). > Warning: If you are using code for `⓵Create web service based on sql` before v1.8.6, do not modify the sponge version under go.mod and upgrade to v1.8.6 or above. Otherwise, the List interface will return empty data because the original `size` field has become invalid (replaced by `limit` field).

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
model.InitDB() model.InitDB()
logger.Infof("init %s succeeded", cfg.Database.Driver) logger.Infof("[%s] was initialized", cfg.Database.Driver)
model.InitCache(cfg.App.CacheType) model.InitCache(cfg.App.CacheType)
if cfg.App.CacheType != "" {
logger.Infof("[%s] was initialized", cfg.App.CacheType)
}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,7 +49,7 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -61,7 +61,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the rpc server connection // initializing the rpc server connection
@@ -74,7 +74,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
//model.InitDB() //model.InitDB()
//logger.Infof("init %s succeeded", cfg.Database.Driver) //logger.Infof("[%s] was initialized", cfg.Database.Driver)
//model.InitCache(cfg.App.CacheType) //model.InitCache(cfg.App.CacheType)
//if cfg.App.CacheType != "" {
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
//}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
//model.InitDB() //model.InitDB()
//logger.Infof("init %s succeeded", cfg.Database.Driver) //logger.Infof("[%s] was initialized", cfg.Database.Driver)
//model.InitCache(cfg.App.CacheType) //model.InitCache(cfg.App.CacheType)
//if cfg.App.CacheType != "" {
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
//}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
model.InitDB() model.InitDB()
logger.Infof("init %s succeeded", cfg.Database.Driver) logger.Infof("[%s] was initialized", cfg.Database.Driver)
model.InitCache(cfg.App.CacheType) model.InitCache(cfg.App.CacheType)
if cfg.App.CacheType != "" {
logger.Infof("[%s] was initialized", cfg.App.CacheType)
}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
//model.InitDB() //model.InitDB()
//logger.Infof("init %s succeeded", cfg.Database.Driver) //logger.Infof("[%s] was initialized", cfg.Database.Driver)
//model.InitCache(cfg.App.CacheType) //model.InitCache(cfg.App.CacheType)
//if cfg.App.CacheType != "" {
// logger.Infof("[%s] was initialized", cfg.App.CacheType)
//}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -49,12 +49,15 @@ func InitApp() {
panic(err) panic(err)
} }
logger.Debug(config.Show()) logger.Debug(config.Show())
logger.Info("init logger succeeded") logger.Info("[logger] was initialized")
// initializing database // initializing database
model.InitDB() model.InitDB()
logger.Infof("init %s succeeded", cfg.Database.Driver) logger.Infof("[%s] was initialized", cfg.Database.Driver)
model.InitCache(cfg.App.CacheType) model.InitCache(cfg.App.CacheType)
if cfg.App.CacheType != "" {
logger.Infof("[%s] was initialized", cfg.App.CacheType)
}
// initializing tracing // initializing tracing
if cfg.App.EnableTrace { if cfg.App.EnableTrace {
@@ -66,7 +69,7 @@ func InitApp() {
strconv.Itoa(cfg.Jaeger.AgentPort), strconv.Itoa(cfg.Jaeger.AgentPort),
cfg.App.TracingSamplingRate, cfg.App.TracingSamplingRate,
) )
logger.Info("init tracer succeeded") logger.Info("[tracer] was initialized")
} }
// initializing the print system and process resources // initializing the print system and process resources
@@ -75,7 +78,7 @@ func InitApp() {
stat.WithLog(logger.Get()), stat.WithLog(logger.Get()),
stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them stat.WithAlarm(), // invalid if it is windows, the default threshold for cpu and memory is 0.8, you can modify them
) )
logger.Info("init statistics succeeded") logger.Info("[resource statistics] was initialized")
} }
} }

View File

@@ -67,7 +67,7 @@ wrk -t2 -c10 -d10s http://192.168.3.27:8080/api/v1/course/1
监控界面如下图所示: 监控界面如下图所示:
![http-grafana](https://go-sponge.com/assets/images/http-grafana.jpg) ![http-grafana](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/http-grafana.jpg)
<br> <br>
@@ -103,7 +103,7 @@ wrk -t2 -c10 -d10s http://192.168.3.27:8080/api/v1/course/1
使用`Goland` IDE打开`internal/service/teacher_client_test.go`文件,对**Test_teacherService_methods** 或 **Test_teacherService_benchmark** 下各个方法进行测试。 使用`Goland` IDE打开`internal/service/teacher_client_test.go`文件,对**Test_teacherService_methods** 或 **Test_teacherService_benchmark** 下各个方法进行测试。
监控界面如下图所示。 监控界面如下图所示。
![rpc-grafana](https://go-sponge.com/assets/images/rpc-grafana.jpg) ![rpc-grafana](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/rpc-grafana.jpg)
<br> <br>

View File

@@ -67,7 +67,7 @@ wrk -t2 -c10 -d10s http://192.168.3.27:8080/api/v1/course/1
The monitoring interface will look like the following image: The monitoring interface will look like the following image:
![http-grafana](https://go-sponge.com/assets/images/http-grafana.jpg) ![http-grafana](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/http-grafana.jpg)
<br> <br>
@@ -104,7 +104,7 @@ Open the `internal/service/teacher_client_test.go` file using the `Goland` IDE a
The monitoring interface will look like the following image: The monitoring interface will look like the following image:
![rpc-grafana](https://go-sponge.com/assets/images/rpc-grafana.jpg) ![rpc-grafana](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/rpc-grafana.jpg)
<br> <br>

View File

@@ -36,7 +36,7 @@ make run
复制 [http://localhost:8080/swagger/index.html](http://localhost:8080/apis/swagger/index.html) 到浏览器访问swagger主页以请求get查询为例连续请求同一个id两次链路跟踪如下图所示。 复制 [http://localhost:8080/swagger/index.html](http://localhost:8080/apis/swagger/index.html) 到浏览器访问swagger主页以请求get查询为例连续请求同一个id两次链路跟踪如下图所示。
![one-server-trace](https://go-sponge.com/assets/images/one-server-trace.jpg) ![one-server-trace](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/one-server-trace.jpg)
<br> <br>
@@ -76,7 +76,7 @@ defer span.End()
启动 **shopgw**、**product**、**inventory**、**comment** 四个服务,在浏览器访问 [http://localhost:8080/apis/swagger/index.html](http://localhost:8080/apis/swagger/index.html) 执行get请求链路跟踪界面如下图所示。 启动 **shopgw**、**product**、**inventory**、**comment** 四个服务,在浏览器访问 [http://localhost:8080/apis/swagger/index.html](http://localhost:8080/apis/swagger/index.html) 执行get请求链路跟踪界面如下图所示。
![multi-servers-trace](https://go-sponge.com/assets/images/multi-servers-trace.jpg) ![multi-servers-trace](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/multi-servers-trace.jpg)
<br> <br>

View File

@@ -35,7 +35,7 @@ make run
Copy [http://localhost:8080/swagger/index.html](http://localhost:8080/apis/swagger/index.html) into your browser to access the Swagger homepage. As an example, for a GET request, make two consecutive requests with the same ID. The distributed tracing results are shown in the following image: Copy [http://localhost:8080/swagger/index.html](http://localhost:8080/apis/swagger/index.html) into your browser to access the Swagger homepage. As an example, for a GET request, make two consecutive requests with the same ID. The distributed tracing results are shown in the following image:
![one-server-trace](https://go-sponge.com/assets/images/one-server-trace.jpg) ![one-server-trace](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/one-server-trace.jpg)
From the image, you can see that the first request consists of 4 spans: From the image, you can see that the first request consists of 4 spans:
@@ -73,7 +73,7 @@ In the **product**, **inventory**, and **comment** services, locate the template
Start the **shopgw**, **product**, **inventory**, and **comment** services. Access [http://localhost:8080/apis/swagger/index.html](http://localhost:8080/apis/swagger/index.html) in your browser and execute a GET request. The distributed tracing interface will look like the image below: Start the **shopgw**, **product**, **inventory**, and **comment** services. Access [http://localhost:8080/apis/swagger/index.html](http://localhost:8080/apis/swagger/index.html) in your browser and execute a GET request. The distributed tracing interface will look like the image below:
![multi-servers-trace](https://go-sponge.com/assets/images/multi-servers-trace.jpg) ![multi-servers-trace](https://raw.githubusercontent.com/zhufuyi/sponge_examples/main/assets/multi-servers-trace.jpg)
From the image, you can see a total of 10 spans in the primary trace: From the image, you can see a total of 10 spans in the primary trace: