Skip to content

Commit 6937fb0

Browse files
peerless1024evelynwei
andauthored
chore/update-examples (#254)
* chore: update examples * chore: update yamls --------- Co-authored-by: evelynwei <[email protected]>
1 parent 7eaada6 commit 6937fb0

File tree

47 files changed

+4568
-197
lines changed

Some content is hidden

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

47 files changed

+4568
-197
lines changed

examples/activehealthcheck/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/circuitbreaker/callee/provider-a/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/circuitbreaker/callee/provider-b/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/circuitbreaker/instance/consumer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/circuitbreaker/instance/consumer/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ func (svr *PolarisClient) runWebServer() {
9393
http.HandleFunc("/echo", func(rw http.ResponseWriter, r *http.Request) {
9494
log.Printf("start to invoke getOneInstance operation")
9595
instance, err := svr.discoverInstance()
96-
if err != nil {
96+
if err != nil || instance == nil {
9797
rw.WriteHeader(http.StatusInternalServerError)
98-
_, _ = rw.Write([]byte(fmt.Sprintf("[errot] discover instance fail : %s", err)))
98+
instanceIsNil := instance == nil
99+
msg := fmt.Sprintf("fail to getOneInstance, err is %v, instance is nil:%v", err, instanceIsNil)
100+
_, _ = rw.Write([]byte(fmt.Sprintf("[error] discover instance fail : %s", msg)))
99101
return
100102
}
101103
start := time.Now()
@@ -178,14 +180,17 @@ func (svr *PolarisClient) printAllInstances() {
178180

179181
func (svr *PolarisClient) reportCircuitBreak(instance model.Instance, status model.RetStatus,
180182
retCode string, start time.Time) {
181-
insRes, _ := model.NewInstanceResource(&model.ServiceKey{
183+
insRes, err := model.NewInstanceResource(&model.ServiceKey{
182184
Namespace: calleeNamespace,
183185
Service: calleeService,
184186
}, &model.ServiceKey{
185187
Namespace: selfNamespace,
186188
Service: selfService,
187189
}, "http", instance.GetHost(), instance.GetPort())
188-
190+
if err != nil {
191+
log.Printf("[error] fail to createInstanceResource, err is %v", err)
192+
return
193+
}
189194
log.Printf("report circuitBreaker [%v] for instance %s/%s:%d "+
190195
"caller [%s.%s] "+
191196
"delay [%v] "+

examples/circuitbreaker/interface/consumer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/circuitbreaker/service/consumer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/configuration/crud/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77

88
.PHONY: build
99
build: clean
10-
go build -o bin main.go
10+
go build -o bin *.go
1111

1212
.PHONY: run
1313
run: build

examples/mock/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GOPATH ?= $(shell go env GOPATH)
2+
3+
# Ensure GOPATH is set before running build process.
4+
ifeq "$(GOPATH)" ""
5+
$(error Please set the environment variable GOPATH before running `make`)
6+
endif
7+
8+
.PHONY: build
9+
build: clean
10+
go build -o bin *.go
11+
12+
.PHONY: run
13+
run: build
14+
./bin
15+
16+
.PHONY: clean
17+
clean:
18+
rm -f bin
19+
rm -rf polaris
20+

examples/mock/go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
module github.com/polarismesh/polaris-go-quickstart-provider
1+
module polarismesh/polaris-go/examples/mock
22

33
go 1.24
44

5+
replace github.com/polarismesh/polaris-go => ../../
6+
57
require github.com/polarismesh/polaris-go v1.6.1
68

79
require (
@@ -10,9 +12,9 @@ require (
1012
github.com/dlclark/regexp2 v1.7.0 // indirect
1113
github.com/golang/protobuf v1.5.2 // indirect
1214
github.com/google/uuid v1.3.0 // indirect
13-
github.com/hashicorp/errwrap v1.1.0 // indirect
15+
github.com/hashicorp/errwrap v1.0.0 // indirect
1416
github.com/hashicorp/go-multierror v1.1.1 // indirect
15-
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
17+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
1618
github.com/mitchellh/go-homedir v1.1.0 // indirect
1719
github.com/modern-go/reflect2 v1.0.2 // indirect
1820
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
@@ -23,8 +25,8 @@ require (
2325
github.com/prometheus/common v0.32.1 // indirect
2426
github.com/prometheus/procfs v0.7.3 // indirect
2527
github.com/spaolacci/murmur3 v1.1.0 // indirect
26-
go.uber.org/atomic v1.10.0 // indirect
27-
go.uber.org/multierr v1.8.0 // indirect
28+
go.uber.org/atomic v1.7.0 // indirect
29+
go.uber.org/multierr v1.6.0 // indirect
2830
go.uber.org/zap v1.21.0 // indirect
2931
golang.org/x/net v0.2.0 // indirect
3032
golang.org/x/sys v0.2.0 // indirect
@@ -34,5 +36,3 @@ require (
3436
google.golang.org/protobuf v1.28.1 // indirect
3537
gopkg.in/yaml.v2 v2.4.0 // indirect
3638
)
37-
38-
replace github.com/polarismesh/polaris-go => ../../

0 commit comments

Comments
 (0)