|
|
@ -7,10 +7,11 @@ import ( |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kratos/kratos/v2/registry" |
|
|
|
|
|
|
|
"github.com/nacos-group/nacos-sdk-go/clients" |
|
|
|
"github.com/nacos-group/nacos-sdk-go/clients" |
|
|
|
"github.com/nacos-group/nacos-sdk-go/common/constant" |
|
|
|
"github.com/nacos-group/nacos-sdk-go/common/constant" |
|
|
|
"github.com/nacos-group/nacos-sdk-go/vo" |
|
|
|
"github.com/nacos-group/nacos-sdk-go/vo" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/go-kratos/kratos/v2/registry" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func getIntranetIP() string { |
|
|
|
func getIntranetIP() string { |
|
|
@ -88,15 +89,18 @@ func TestRegistry(t *testing.T) { |
|
|
|
r := New(client) |
|
|
|
r := New(client) |
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
var w registry.Watcher |
|
|
|
var ( |
|
|
|
w, err = r.Watch(ctx, "golang-sms@grpc") |
|
|
|
w registry.Watcher |
|
|
|
if err != nil { |
|
|
|
watchErr error |
|
|
|
log.Fatal(err) |
|
|
|
) |
|
|
|
|
|
|
|
w, watchErr = r.Watch(ctx, "golang-sms@grpc") |
|
|
|
|
|
|
|
if watchErr != nil { |
|
|
|
|
|
|
|
log.Fatal(watchErr) |
|
|
|
} |
|
|
|
} |
|
|
|
for { |
|
|
|
for { |
|
|
|
var res []*registry.ServiceInstance |
|
|
|
var res []*registry.ServiceInstance |
|
|
|
res, err = w.Next() |
|
|
|
res, watchErr = w.Next() |
|
|
|
if err != nil { |
|
|
|
if watchErr != nil { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Printf("watch: %d", len(res)) |
|
|
|
log.Printf("watch: %d", len(res)) |
|
|
|