Skip to content

Commit 5f1f8a9

Browse files
committed
adapt to go chassis 2.4.0; remove istio example; unify go.mod
1 parent 6e51a02 commit 5f1f8a9

File tree

62 files changed

+179
-1098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+179
-1098
lines changed

archaius/cse/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package main
22

33
import _ "github.com/huaweicse/auth/adaptor/gochassis"
44
import (
5-
"github.com/go-chassis/go-chassis"
65
"github.com/go-chassis/go-chassis-examples/archaius/resource"
7-
"github.com/go-chassis/go-chassis/core/server"
8-
"github.com/go-mesh/openlogging"
6+
"github.com/go-chassis/go-chassis/v2"
7+
"github.com/go-chassis/go-chassis/v2/core/server"
8+
"github.com/go-chassis/openlog"
99
)
1010

1111
func main() {
1212
chassis.RegisterSchema("rest", &resource.Hello{}, server.WithSchemaID("Hello"))
1313
err := chassis.Init()
1414
if err != nil {
15-
openlogging.GetLogger().Error(err.Error())
15+
openlog.Error(err.Error())
1616
return
1717
}
1818
chassis.Run()

archaius/local/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ package main
22

33
import (
44
"github.com/go-chassis/go-archaius"
5-
"github.com/go-chassis/go-archaius/source/file"
6-
"github.com/go-chassis/go-chassis"
5+
"github.com/go-chassis/go-archaius/source/util"
76
"github.com/go-chassis/go-chassis-examples/archaius/resource"
8-
"github.com/go-mesh/openlogging"
7+
"github.com/go-chassis/go-chassis/v2"
8+
"github.com/go-chassis/openlog"
99
)
1010

1111
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/server/
1212

1313
func main() {
1414
chassis.RegisterSchema("rest", &resource.Hello{})
1515
if err := chassis.Init(); err != nil {
16-
openlogging.Error("Init failed." + err.Error())
16+
openlog.Error("Init failed." + err.Error())
1717
return
1818
}
1919
//Add your custom file to archaius
20-
if err := archaius.AddFile("./conf/custom.yaml", archaius.WithFileHandler(filesource.UseFileNameAsKeyContentAsValue)); err != nil {
21-
openlogging.Error("add file configurations failed." + err.Error())
20+
if err := archaius.AddFile("./conf/custom.yaml", archaius.WithFileHandler(util.UseFileNameAsKeyContentAsValue)); err != nil {
21+
openlog.Error("add file configurations failed." + err.Error())
2222
return
2323
}
2424
//Add your custom file to archaius
2525
if err := archaius.AddFile("./conf/props.yaml"); err != nil {
26-
openlogging.Error("add props configurations failed." + err.Error())
26+
openlog.Error("add props configurations failed." + err.Error())
2727
return
2828
}
2929
chassis.Run()

archaius/resource/restful_hello.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55

66
"github.com/go-chassis/go-archaius"
7-
rf "github.com/go-chassis/go-chassis/server/restful"
7+
rf "github.com/go-chassis/go-chassis/v2/server/restful"
88
"sync"
99
)
1010

canaryrelease/client/main.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"context"
55
"time"
66

7-
"github.com/go-chassis/go-chassis"
87
_ "github.com/go-chassis/go-chassis/bootstrap"
98
"github.com/go-chassis/go-chassis/client/rest"
109
"github.com/go-chassis/go-chassis/core"
1110
"github.com/go-chassis/go-chassis/pkg/util/httputil"
12-
"github.com/go-mesh/openlogging"
11+
"github.com/go-chassis/go-chassis/v2"
12+
"github.com/go-chassis/openlog"
1313
)
1414

1515
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/rest/client/
@@ -20,49 +20,46 @@ import (
2020
func main() {
2121
//Init framework
2222
if err := chassis.Init(); err != nil {
23-
openlogging.Error("Init failed." + err.Error())
23+
openlog.Error("Init failed." + err.Error())
2424
return
2525
}
2626

2727
for i := 0; i < 10; i++ {
2828
req, err := rest.NewRequest("GET", "http://carts/list", nil)
2929
if err != nil {
30-
openlogging.Error("new request failed.")
30+
openlog.Error("new request failed.")
3131
return
3232
}
3333

34-
3534
//req.Header.Set("Chassis", "info")
3635

3736
resp, err := core.NewRestInvoker().ContextDo(context.Background(), req)
3837
if err != nil {
39-
openlogging.Error("do request failed.")
38+
openlog.Error("do request failed.")
4039
return
4140
}
4241
defer resp.Body.Close()
43-
openlogging.Info("carts Server return : " + string(httputil.ReadBody(resp)))
42+
openlog.Info("carts Server return : " + string(httputil.ReadBody(resp)))
4443

4544
time.Sleep(1 * time.Second)
4645
}
4746

48-
4947
for i := 0; i < 10; i++ {
5048
req, err := rest.NewRequest("GET", "http://carts/list", nil)
5149
if err != nil {
52-
openlogging.Error("new request failed.")
50+
openlog.Error("new request failed.")
5351
return
5452
}
5553

56-
5754
req.Header.Set("os", "ios")
5855

5956
resp, err := core.NewRestInvoker().ContextDo(context.Background(), req)
6057
if err != nil {
61-
openlogging.Error("do request failed.")
58+
openlog.Error("do request failed.")
6259
return
6360
}
6461
defer resp.Body.Close()
65-
openlogging.Info("carts Server return : " + string(httputil.ReadBody(resp)))
62+
openlog.Info("carts Server return : " + string(httputil.ReadBody(resp)))
6663

6764
time.Sleep(1 * time.Second)
6865
}

canaryrelease/serverV1/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package main
22

33
import (
4-
"github.com/go-chassis/go-chassis"
54
"github.com/go-chassis/go-chassis-examples/canaryrelease/serverV1/resource"
6-
"github.com/go-mesh/openlogging"
5+
"github.com/go-chassis/go-chassis/v2"
6+
"github.com/go-chassis/openlog"
77
)
88

99
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/rpc/server/
1010

1111
func main() {
1212
chassis.RegisterSchema("rest", &resource.RestFulRouterA{})
1313
if err := chassis.Init(); err != nil {
14-
openlogging.Error("Init failed." + err.Error())
14+
openlog.Error("Init failed." + err.Error())
1515
return
1616
}
1717
chassis.Run()

canaryrelease/serverV1/resource/restful_router_V1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package resource
22

33
import (
4-
"github.com/go-chassis/go-chassis/server/restful"
4+
"github.com/go-chassis/go-chassis/v2/server/restful"
55
"net/http"
66
)
77

canaryrelease/serverV2/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package main
22

33
import (
4-
"github.com/go-chassis/go-chassis"
54
"github.com/go-chassis/go-chassis-examples/canaryrelease/serverV2/resource"
6-
"github.com/go-mesh/openlogging"
5+
"github.com/go-chassis/go-chassis/v2"
6+
"github.com/go-chassis/openlog"
77
)
88

99
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/rpc/server/
1010

1111
func main() {
1212
chassis.RegisterSchema("rest", &resource.RestFulRouterB{})
1313
if err := chassis.Init(); err != nil {
14-
openlogging.Error("Init failed." + err.Error())
14+
openlog.Error("Init failed." + err.Error())
1515
return
1616
}
1717
chassis.Run()

canaryrelease/serverV2/resource/restful_router_V2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package resource
22

33
import (
4-
"github.com/go-chassis/go-chassis/server/restful"
4+
"github.com/go-chassis/go-chassis/v2/server/restful"
55
"net/http"
66
)
77

circuit/client/main.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
package main
22

33
import (
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/
1717
func 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() {
3838
func 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
}
7878
func 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

circuit/server/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package main
22

33
import (
4-
"github.com/go-chassis/go-chassis"
54
"github.com/go-chassis/go-chassis-examples/circuit/server/resource"
6-
_ "github.com/go-chassis/go-chassis/bootstrap"
7-
"github.com/go-mesh/openlogging"
5+
"github.com/go-chassis/go-chassis/v2"
6+
_ "github.com/go-chassis/go-chassis/v2/bootstrap"
7+
"github.com/go-chassis/openlog"
88
)
99

1010
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/circuit/server/
1111
func main() {
1212
chassis.RegisterSchema("rest", &resource.CircuitResource{})
1313
//start all server you register in server/schemas.
1414
if err := chassis.Init(); err != nil {
15-
openlogging.Error("Init failed." + err.Error())
15+
openlog.Error("Init failed." + err.Error())
1616
return
1717
}
1818
chassis.Run()

0 commit comments

Comments
 (0)