11package main
22
33import (
4- "github.com/go-chassis/go-chassis"
4+ "github.com/go-chassis/go-chassis/v2 "
55
66 "context"
77
8- _ "github.com/go-chassis/go-chassis/bootstrap"
9- "github.com/go-chassis/go-chassis/client/rest"
10- "github.com/go-chassis/go-chassis/core"
11- "github.com/go-chassis/go-chassis/pkg/util/httputil"
12- "github.com/go-mesh/openlogging "
8+ _ "github.com/go-chassis/go-chassis/v2/ bootstrap"
9+ "github.com/go-chassis/go-chassis/v2/ client/rest"
10+ "github.com/go-chassis/go-chassis/v2/ core"
11+ "github.com/go-chassis/go-chassis/v2/ pkg/util/httputil"
12+ "github.com/go-chassis/openlog "
1313 "sync"
1414)
1515
1616//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/circuit/client/
1717func main () {
1818 //Init framework
1919 if err := chassis .Init (); err != nil {
20- openlogging .Error ("Init failed." + err .Error ())
20+ openlog .Error ("Init failed." + err .Error ())
2121 return
2222 }
2323 for i := 0 ; i < 100 ; i ++ {
@@ -38,19 +38,19 @@ func main() {
3838func callError () {
3939 req , err := rest .NewRequest ("GET" , "http://CircuitServer/error" , nil )
4040 if err != nil {
41- openlogging .GetLogger ().Error ("new request failed." )
41+ openlog .GetLogger ().Error ("new request failed." )
4242 return
4343 }
4444 resp , err := core .NewRestInvoker ().ContextDo (context .TODO (), req )
4545 if resp != nil {
4646 if resp .Body != nil {
47- openlogging .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
47+ openlog .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
4848 defer resp .Body .Close ()
4949 }
5050 }
5151
5252 if err != nil {
53- openlogging .GetLogger ().Error ("request failed: " + err .Error ())
53+ openlog .GetLogger ().Error ("request failed: " + err .Error ())
5454 return
5555 }
5656
@@ -59,37 +59,37 @@ func callConcurrency(wg *sync.WaitGroup) {
5959 defer wg .Done ()
6060 req , err := rest .NewRequest ("GET" , "http://CircuitServer/concurrency" , nil )
6161 if err != nil {
62- openlogging .Error ("new request failed." )
62+ openlog .Error ("new request failed." )
6363 return
6464 }
6565 resp , err := core .NewRestInvoker ().ContextDo (context .TODO (), req )
6666 if resp != nil {
6767 if resp .Body != nil {
6868 defer resp .Body .Close ()
69- openlogging .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
69+ openlog .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
7070 }
7171 }
7272 if err != nil {
73- openlogging .GetLogger ().Error ("request failed: " + err .Error ())
73+ openlog .GetLogger ().Error ("request failed: " + err .Error ())
7474 return
7575 }
7676
7777}
7878func callDeadlock () {
7979 req , err := rest .NewRequest ("GET" , "http://CircuitServer/lock" , nil )
8080 if err != nil {
81- openlogging .Error ("new request failed." )
81+ openlog .Error ("new request failed." )
8282 return
8383 }
8484 resp , err := core .NewRestInvoker ().ContextDo (context .TODO (), req )
8585 if resp != nil {
8686 if resp .Body != nil {
8787 defer resp .Body .Close ()
88- openlogging .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
88+ openlog .GetLogger ().Info ("response body: " + string (httputil .ReadBody (resp )))
8989 }
9090 }
9191 if err != nil {
92- openlogging .GetLogger ().Error ("request failed: " + err .Error ())
92+ openlog .GetLogger ().Error ("request failed: " + err .Error ())
9393 return
9494 }
9595
0 commit comments