Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gogf/gf into feature-clic…
Browse files Browse the repository at this point in the history
…khouse-driver
  • Loading branch information
DGuang21 committed May 19, 2022
2 parents 796f19e + 896b9fa commit 04dd88e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- 8123:8123
- 9001:9001
polaris:
image: huyuanxin/polaris-server-with-config:latest
image: houseme/polaris-server-with-config:latest
ports:
- 8090:8090
- 8091:8091
Expand Down
30 changes: 25 additions & 5 deletions contrib/registry/polaris/polaris_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

"github.com/polarismesh/polaris-go/api"
"github.com/polarismesh/polaris-go/pkg/config"

"github.com/gogf/gf/v2/frame/g"
Expand All @@ -21,7 +22,11 @@ import (
// TestRegistry TestRegistryManyService
func TestRegistry(t *testing.T) {
conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"})

conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
t.Fatal(err)
}
r := NewWithConfig(
conf,
WithTimeout(time.Second*10),
Expand All @@ -38,7 +43,7 @@ func TestRegistry(t *testing.T) {
Separator: instanceIDSeparator,
}

err := r.Register(ctx, svc)
err = r.Register(ctx, svc)
if err != nil {
t.Fatal(err)
}
Expand All @@ -52,6 +57,12 @@ func TestRegistry(t *testing.T) {
// TestRegistryMany TestRegistryManyService
func TestRegistryMany(t *testing.T) {
conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"})
conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")

err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
t.Fatal(err)
}

r := NewWithConfig(
conf,
Expand Down Expand Up @@ -81,7 +92,7 @@ func TestRegistryMany(t *testing.T) {
Separator: instanceIDSeparator,
}

err := r.Register(context.Background(), svc)
err = r.Register(context.Background(), svc)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -115,6 +126,11 @@ func TestRegistryMany(t *testing.T) {
// TestGetService Test GetService
func TestGetService(t *testing.T) {
conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"})
conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
t.Fatal(err)
}

r := NewWithConfig(
conf,
Expand All @@ -132,7 +148,7 @@ func TestGetService(t *testing.T) {
Separator: instanceIDSeparator,
}

err := r.Register(ctx, svc)
err = r.Register(ctx, svc)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -161,7 +177,11 @@ func TestGetService(t *testing.T) {
// TestWatch Test Watch
func TestWatch(t *testing.T) {
conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"})

conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
t.Fatal(err)
}
r := NewWithConfig(
conf,
WithTimeout(time.Second*10),
Expand Down
8 changes: 7 additions & 1 deletion example/registry/polaris/client/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
package main

import (
"context"
"fmt"
"time"

"github.com/polarismesh/polaris-go/api"
"github.com/polarismesh/polaris-go/pkg/config"

"github.com/gogf/gf/contrib/registry/polaris/v2"

"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/gsvc"
"github.com/gogf/gf/v2/os/gctx"
)

func main() {
conf := config.NewDefaultConfiguration([]string{"192.168.100.222:8091"})
conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
g.Log().Fatal(context.Background(), err)
}

gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(100)))

Expand Down
8 changes: 8 additions & 0 deletions example/registry/polaris/server/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package main

import (
"context"

"github.com/polarismesh/polaris-go/api"
"github.com/polarismesh/polaris-go/pkg/config"

"github.com/gogf/gf/contrib/registry/polaris/v2"
Expand All @@ -11,6 +14,11 @@ import (

func main() {
conf := config.NewDefaultConfiguration([]string{"192.168.100.222:8091"})
conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup")
err := api.SetLoggersDir("/tmp/polaris/log")
if err != nil {
g.Log().Fatal(context.Background(), err)
}

// TTL egt 2*time.Second
gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(100)))
Expand Down

0 comments on commit 04dd88e

Please sign in to comment.