Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f8fab43
commit 29174c4
Showing
14 changed files
with
203 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Quik start with examples | ||
|
||
1. Launch service center | ||
```sh | ||
cd examples | ||
docker-compose up | ||
``` | ||
|
||
2. Run rest server | ||
|
||
```sh | ||
cd serverA | ||
export CHASSIS_HOME=$PWD | ||
go run main.go | ||
|
||
``` | ||
```sh | ||
cd serverB | ||
export CHASSIS_HOME=$PWD | ||
go run main.go | ||
|
||
``` | ||
3. Run Rest client | ||
```sh | ||
cd client | ||
export CHASSIS_HOME=$PWD | ||
go run main.go | ||
|
||
``` | ||
|
||
4. check zikpin at http://127.0.0.1:9411 | ||
|
||
5. check metrics at http://127.0.0.1:5001 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
#APPLICATION_ID: CSE optional | ||
cse: | ||
service: | ||
registry: | ||
address: http://127.0.0.1:30100 | ||
handler: | ||
chain: | ||
Consumer: | ||
default: bizkeeper-consumer,router,loadbalance,tracing-consumer,ratelimiter-consumer,transport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
#微服务的私有属性 | ||
service_description: | ||
name: RESTClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cse: | ||
metrics: | ||
apiPath: /metrics # we can also give api path having prefix "/" ,like /someurl/metrics | ||
enable: true | ||
enableGoRuntimeMetrics: true | ||
flushInterval: 10s | ||
tracing: | ||
tracer: zipkin | ||
settings: | ||
collector: http | ||
URI: http://127.0.0.1:9411/api/v1/spans | ||
batchSize: 1 | ||
batchInterval: 1s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-chassis/go-chassis" | ||
_ "github.com/go-chassis/go-chassis-plugins/tracing/zipkin" | ||
_ "github.com/go-chassis/go-chassis/bootstrap" | ||
"github.com/go-chassis/go-chassis/client/rest" | ||
"github.com/go-chassis/go-chassis/core" | ||
"github.com/go-chassis/go-chassis/core/lager" | ||
"github.com/go-chassis/go-chassis/pkg/util/httputil" | ||
"time" | ||
) | ||
|
||
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/client/ | ||
func main() { | ||
//Init framework | ||
if err := chassis.Init(); err != nil { | ||
lager.Logger.Error("Init failed." + err.Error()) | ||
return | ||
} | ||
|
||
req, err := rest.NewRequest("GET", "http://RESTServerA/trace", nil) | ||
if err != nil { | ||
lager.Logger.Error("new request failed." + err.Error()) | ||
return | ||
} | ||
|
||
resp, err := core.NewRestInvoker().ContextDo(context.TODO(), req) | ||
if err != nil { | ||
lager.Logger.Error("do request failed." + err.Error()) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
lager.Logger.Info("REST Server sayhello[GET]: " + string(httputil.ReadBody(resp))) | ||
time.Sleep(2 * time.Second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
cse: | ||
service: | ||
registry: | ||
address: http://127.0.0.1:30100 # If type is File then address will be the path of the file | ||
protocols: | ||
rest: | ||
listenAddress: 127.0.0.1:5001 | ||
advertiseAddress: 127.0.0.1:5001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
#微服务的私有属性 | ||
service_description: | ||
name: RESTServerA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cse: | ||
metrics: | ||
apiPath: /metrics # we can also give api path having prefix "/" ,like /adas/metrics | ||
enable: true | ||
enableGoRuntimeMetrics: true | ||
flushInterval: 10s | ||
tracing: | ||
tracer: zipkin | ||
settings: | ||
URI: http://127.0.0.1:9411/api/v1/spans | ||
batchSize: 1 | ||
batchInterval: 1s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/go-chassis/go-chassis" | ||
"github.com/go-chassis/go-chassis/core/lager" | ||
"github.com/go-chassis/go-chassis/core/server" | ||
"github.com/go-chassis/go-chassis/examples/schemas" | ||
//tracers | ||
_ "github.com/go-chassis/go-chassis-plugins/tracing/zipkin" | ||
) | ||
|
||
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/serverA/ | ||
|
||
func main() { | ||
chassis.RegisterSchema("rest", &schemas.TracingHello{}, server.WithSchemaID("TracingHello")) | ||
if err := chassis.Init(); err != nil { | ||
lager.Logger.Error("Init failed." + err.Error()) | ||
return | ||
} | ||
chassis.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
cse: | ||
service: | ||
registry: | ||
address: http://127.0.0.1:30100 # If type is File then address will be the path of the file | ||
protocols: | ||
rest: | ||
listenAddress: 127.0.0.1:5002 | ||
advertiseAddress: 127.0.0.1:5002 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
#微服务的私有属性 | ||
service_description: | ||
name: RESTServerB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cse: | ||
metrics: | ||
apiPath: /metrics # we can also give api path having prefix "/" ,like /adas/metrics | ||
enable: true | ||
enableGoRuntimeMetrics: true | ||
flushInterval: 10s | ||
tracing: | ||
tracer: zipkin | ||
settings: | ||
URI: http://127.0.0.1:9411/api/v1/spans | ||
batchSize: 1 | ||
batchInterval: 1s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
//tracers | ||
_ "github.com/go-chassis/go-chassis-plugins/tracing/zipkin" | ||
|
||
"github.com/go-chassis/go-chassis" | ||
"github.com/go-chassis/go-chassis/core/server" | ||
"github.com/go-chassis/go-chassis/examples/schemas" | ||
"github.com/go-mesh/openlogging" | ||
) | ||
|
||
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/{path}/{to}/serverB/ | ||
|
||
func main() { | ||
chassis.RegisterSchema("rest", &schemas.RestFulHello{}, server.WithSchemaID("RestHelloService")) | ||
if err := chassis.Init(); err != nil { | ||
openlogging.Error("Init failed." + err.Error()) | ||
return | ||
} | ||
chassis.Run() | ||
} |