From a98f2a047133a4b6776204f57321169ca0fe0192 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Thu, 26 May 2022 10:22:17 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=B0=B1?= =?UTF-8?q?=E8=BF=91=E8=B7=AF=E7=94=B1=E6=94=AF=E6=8C=81=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/quickstart/provider/main.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/quickstart/provider/main.go b/examples/quickstart/provider/main.go index b611f08a..3a09fa84 100644 --- a/examples/quickstart/provider/main.go +++ b/examples/quickstart/provider/main.go @@ -122,6 +122,23 @@ func (svr *PolarisProvider) deregisterService() { log.Fatalf("fail to deregister instance, err is %v", err) } log.Printf("deregister successfully.") + go svr.doHeartbeat() +} + +func (svr *PolarisProvider) doHeartbeat() { + log.Printf("start to invoke heartbeat operation") + ticker := time.NewTicker(time.Duration(5 * time.Second)) + for range ticker.C { + if !svr.isShutdown { + heartbeatRequest := &polaris.InstanceHeartbeatRequest{} + heartbeatRequest.Namespace = namespace + heartbeatRequest.Service = service + heartbeatRequest.Host = svr.host + heartbeatRequest.Port = svr.port + heartbeatRequest.ServiceToken = token + svr.provider.Heartbeat(heartbeatRequest) + } + } } func (svr *PolarisProvider) runMainLoop() { From ef707119a52124291f7ff65aae784b9216c6f71b Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Fri, 12 Aug 2022 12:09:32 +0800 Subject: [PATCH 2/5] rebase upstream/master --- examples/quickstart/provider/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/quickstart/provider/main.go b/examples/quickstart/provider/main.go index 3a09fa84..ec0fde2c 100644 --- a/examples/quickstart/provider/main.go +++ b/examples/quickstart/provider/main.go @@ -122,7 +122,6 @@ func (svr *PolarisProvider) deregisterService() { log.Fatalf("fail to deregister instance, err is %v", err) } log.Printf("deregister successfully.") - go svr.doHeartbeat() } func (svr *PolarisProvider) doHeartbeat() { From 4493d5773c8fbbf7fc926375d7dfab83a88d6089 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Tue, 21 Mar 2023 11:50:16 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Ddemo=E4=B8=AD?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1import=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/quickstart/provider/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/quickstart/provider/main.go b/examples/quickstart/provider/main.go index ec0fde2c..42e2efc1 100644 --- a/examples/quickstart/provider/main.go +++ b/examples/quickstart/provider/main.go @@ -27,6 +27,7 @@ import ( "os/signal" "strings" "syscall" + "time" "github.com/polarismesh/polaris-go" ) From d6c5fff92aae065d517ebe5060d47b5e32d30bfd Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Tue, 21 Mar 2023 11:50:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Ddemo=E4=B8=AD?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1import=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/quickstart/provider/main.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/examples/quickstart/provider/main.go b/examples/quickstart/provider/main.go index 42e2efc1..b611f08a 100644 --- a/examples/quickstart/provider/main.go +++ b/examples/quickstart/provider/main.go @@ -27,7 +27,6 @@ import ( "os/signal" "strings" "syscall" - "time" "github.com/polarismesh/polaris-go" ) @@ -125,22 +124,6 @@ func (svr *PolarisProvider) deregisterService() { log.Printf("deregister successfully.") } -func (svr *PolarisProvider) doHeartbeat() { - log.Printf("start to invoke heartbeat operation") - ticker := time.NewTicker(time.Duration(5 * time.Second)) - for range ticker.C { - if !svr.isShutdown { - heartbeatRequest := &polaris.InstanceHeartbeatRequest{} - heartbeatRequest.Namespace = namespace - heartbeatRequest.Service = service - heartbeatRequest.Host = svr.host - heartbeatRequest.Port = svr.port - heartbeatRequest.ServiceToken = token - svr.provider.Heartbeat(heartbeatRequest) - } - } -} - func (svr *PolarisProvider) runMainLoop() { ch := make(chan os.Signal, 1) signal.Notify(ch, []os.Signal{ From 3d6008488c4851f3c0d957db7dd44617fe2ca470 Mon Sep 17 00:00:00 2001 From: chuntaojun Date: Wed, 6 Sep 2023 12:00:18 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=B0=B1=E8=BF=91?= =?UTF-8?q?=E8=B7=AF=E7=94=B1demo=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/route/nearby/provider/go.mod | 2 +- examples/route/nearby/provider/go.sum | 4 ++-- examples/route/nearby/provider/polaris.yaml | 9 +++++---- pkg/config/location_provider.go | 3 +++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/route/nearby/provider/go.mod b/examples/route/nearby/provider/go.mod index 1fff7a25..0b82dabb 100644 --- a/examples/route/nearby/provider/go.mod +++ b/examples/route/nearby/provider/go.mod @@ -17,7 +17,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.3.2-alpha.2 // indirect + github.com/polarismesh/specification v1.4.0 // indirect github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect diff --git a/examples/route/nearby/provider/go.sum b/examples/route/nearby/provider/go.sum index 093a5191..41c830a6 100644 --- a/examples/route/nearby/provider/go.sum +++ b/examples/route/nearby/provider/go.sum @@ -375,8 +375,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA= -github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.4.0 h1:fm7sUtFZC2g9+lLmRCtjGrUow47CY5JDFoZXwwCQGGY= +github.com/polarismesh/specification v1.4.0/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= diff --git a/examples/route/nearby/provider/polaris.yaml b/examples/route/nearby/provider/polaris.yaml index ff77eba2..614bd51b 100644 --- a/examples/route/nearby/provider/polaris.yaml +++ b/examples/route/nearby/provider/polaris.yaml @@ -1,14 +1,15 @@ global: serverConnector: addresses: - - 127.0.0.1:8091 + - 119.91.66.223:8091 # 地址提供插件,用于获取当前SDK所在的地域信息 location: providers: - type: local - region: ${REGION} - zone: ${ZONE} - campus: ${CAMPUS} + options: + region: ${REGION} + zone: ${ZONE} + campus: ${CAMPUS} #描述:主调端配置 statReporter: enable: true diff --git a/pkg/config/location_provider.go b/pkg/config/location_provider.go index 66750fdb..0ce66743 100644 --- a/pkg/config/location_provider.go +++ b/pkg/config/location_provider.go @@ -42,4 +42,7 @@ func (l LocationProviderConfigImpl) Verify() error { } func (l LocationProviderConfigImpl) SetDefault() { + if len(l.Options) == 0 { + l.Options = map[string]interface{}{} + } }