diff --git a/README-zh.md b/README-zh.md index ca9b8c04..88a99674 100644 --- a/README-zh.md +++ b/README-zh.md @@ -1,201 +1,41 @@ -polaris-go -======================================== -北极星polaris是一个支持多种开发语言、兼容主流开发框架的服务治理中心。polaris-go是北极星的Go语言嵌入式服务治理SDK - -## 概述 - -polaris-go提供以下功能特性: - -* ** 服务实例注册,心跳上报 - - 提供API接口供应用上下线时注册/反注册自身实例信息,并且可通过定时上报心跳来通知主调方自身健康状态。 - -* ** 服务发现 - - 提供多种API接口,通过API接口,用户可以获取服务下的全量服务实例,或者获取通过服务治理规则过滤后的一个服务实例,可供业务获取实例后马上发起调用。 - -* ** 故障熔断 - - 提供API接口供应用上报接口调用结果数据,并根据汇总数据快速对故障实例/分组进行隔离,以及在合适的时机进行探测恢复。 - -* ** 服务限流 - - 提供API接口供应用进行配额的检查及划扣,支持按服务级,以及接口级的限流策略。 - -## 快速入门 - -### 前置准备 - - - 在本地启动Polaris服务端。 - - 通过Polaris控制台创建好服务。 - -### 服务实例注册 - -完整的实例代码可参考组件examples下的provider/register的实现,以下为核心逻辑: -```` -//注册服务 -request := &api.InstanceRegisterRequest{} -request.Namespace = namespace -request.Service = service -request.ServiceToken = token -request.Host = ip -request.Port = port -request.SetTTL(2) -resp, err := provider.Register(request) -if nil != err { - log.Fatalf("fail to register instance, err %v", err) -} -log.Printf("success to register instance, id is %s", resp.InstanceID) -```` - -### 服务实例反注册 - -完整的实例代码可参考组件examples下的provider/deregister的实现,以下为核心逻辑: -```` -//反注册服务 -request := &api.InstanceDeRegisterRequest{} -request.Namespace = namespace -request.Service = service -request.ServiceToken = token -request.Host = ip -request.Port = port -err = provider.Deregister(request) -if nil != err { - log.Fatalf("fail to deregister instance, err %v", err) -} -log.Printf("success to deregister instance") -```` - -### 服务实例心跳上报 - -完整的实例代码可参考组件examples下的provider/deregister的实现,以下为核心逻辑: -```` -hbRequest := &api.InstanceHeartbeatRequest{} -hbRequest.Namespace = namespace -hbRequest.Service = service -hbRequest.Host = ip -hbRequest.Port = port -hbRequest.ServiceToken = token -if err = provider.Heartbeat(hbRequest); nil != err { - log.Printf("fail to heartbeat, error is %v", err) -} else { - log.Printf("success to call heartbeat for index %d", i) -} -```` - -### 服务发现 - -#### 获取单个服务实例(走路由和负载均衡) - -完整的实例代码可参考组件examples下的consumer/getoneinstance的实现,以下为核心逻辑: -```` -var getInstancesReq *api.GetOneInstanceRequest -getInstancesReq = &api.GetOneInstanceRequest{} -getInstancesReq.Namespace = namespace -getInstancesReq.Service = service -getInstancesReq.SourceService = svcInfo -getInstancesReq.LbPolicy = lbPolicy -getInstancesReq.HashKey = []byte(hashKey) -startTime := time.Now() -//进行服务发现,获取单一服务实例 -getInstResp, err := consumer.GetOneInstance(getInstancesReq) -if nil != err { - log.Fatalf("fail to sync GetOneInstance, err is %v", err) -} -consumeDuration := time.Since(startTime) -log.Printf("success to sync GetOneInstance, count is %d, consume is %v\n", - len(getInstResp.Instances), consumeDuration) -targetInstance := getInstResp.Instances[0] -log.Printf("sync instance is id=%s, address=%s:%d\n", - targetInstance.GetId(), targetInstance.GetHost(), targetInstance.GetPort()) -```` - -#### 获取全量服务实例 - -完整的实例代码可参考组件examples下的consumer/getallinstances的实现,以下为核心逻辑: -```` -var getAllInstancesReq *api.GetAllInstancesRequest -getAllInstancesReq = &api.GetAllInstancesRequest{} -getAllInstancesReq.Namespace = namespace -getAllInstancesReq.Service = service - -getAllInstResp, err := consumer.GetAllInstances(getAllInstancesReq) -if nil != err { - log.Fatalf("fail to sync GetAllInstances, err is %v", err) -} -log.Printf("success to sync GetAllInstances, count is %d, revision is %s\n", len(getAllInstResp.Instances), - getAllInstResp.Revision) -```` - -### 故障熔断 - -完整的实例代码可参考组件examples下的consumer/circuitbreak的实现,以下为核心逻辑: -```` -//执行服务发现,拉取服务实例,以及上报调用结果 -var getInstancesReq *api.GetOneInstanceRequest -getInstancesReq = &api.GetOneInstanceRequest{} -getInstancesReq.Namespace = namespace -getInstancesReq.Service = service -resp, err := consumer.GetOneInstance(getInstancesReq) -if nil != err { - log.Fatal(err) -} -targetInstance := resp.GetInstances()[0] -addr := fmt.Sprintf("%s:%d", targetInstance.GetHost(), targetInstance.GetPort()) -fmt.Printf("select address is %s\n", addr) -var retStatus model.RetStatus -var retCode int32 -if target == addr { - retStatus = api.RetFail - retCode = 500 -} else { - retStatus = api.RetSuccess - retCode = 200 -} -//构造请求,进行服务调用结果上报 -svcCallResult := &api.ServiceCallResult{} -//设置被调的实例信息 -svcCallResult.SetCalledInstance(targetInstance) -//设置服务调用结果,枚举,成功或者失败 -svcCallResult.SetRetStatus(retStatus) -//设置服务调用返回码 -svcCallResult.SetRetCode(retCode) -//设置服务调用时延信息 -svcCallResult.SetDelay(30 * time.Millisecond) -err = consumer.UpdateServiceCallResult(svcCallResult) -if nil != err { - log.Fatal(err) -} -```` - -### 服务限流 - -完整的实例代码可参考组件examples下的provider/ratelimit的实现,以下为核心逻辑: -```` -//创建访问限流请求 -quotaReq := api.NewQuotaRequest() -//设置命名空间 -quotaReq.SetNamespace(namespace) -//设置服务名 -quotaReq.SetService(service) -//设置标签值 -quotaReq.SetLabels(labels) -//调用配额获取接口 -future, err := limitAPI.GetQuota(quotaReq) -if nil != err { - log.Fatalf("fail to getQuota, err %v", err) -} -resp := future.Get() -if api.QuotaResultOk == resp.Code { - //本次调用不限流,放通,接下来可以处理业务逻辑 - log.Printf("quota result ok") -} else { - //本次调用限流判定不通过,调用受限,需返回错误给主调端 - log.Printf("quota result fail, info is %s", resp.Info) -} -```` - -## License - -The polaris-go is licensed under the BSD 3-Clause License. Copyright and license information can be found in the file [LICENSE](LICENSE) - +polaris-go +======================================== +北极星polaris是一个支持多种开发语言、兼容主流开发框架的服务治理中心。polaris-go是北极星的Go语言嵌入式服务治理SDK + +## 概述 + +polaris-go提供以下功能特性: + +* ** 服务实例注册,心跳上报 + + 提供API接口供应用上下线时注册/反注册自身实例信息,并且可通过定时上报心跳来通知主调方自身健康状态。 + +* ** 服务发现 + + 提供多种API接口,通过API接口,用户可以获取服务下的全量服务实例,或者获取通过服务治理规则过滤后的一个服务实例,可供业务获取实例后马上发起调用。 + +* ** 故障熔断 + + 提供API接口供应用上报接口调用结果数据,并根据汇总数据快速对故障实例/分组进行隔离,以及在合适的时机进行探测恢复。 + +* ** 服务限流 + + 提供API接口供应用进行配额的检查及划扣,支持按服务级,以及接口级的限流策略。 + +## 快速入门 + +### 依赖引入 + +polaris-go通过go mod进行管理,用户可以在go.mod文件中引入polaris-go的依赖 +``` +github.com/polarismesh/polaris-go v1.0.0 +``` + +### 使用API + +API的快速使用指南,可以参考:[QuickStart](sample/quickstart) + +## License + +The polaris-go is licensed under the BSD 3-Clause License. Copyright and license information can be found in the file [LICENSE](LICENSE) + diff --git a/README.md b/README.md index 0b09b4f4..5687849d 100644 --- a/README.md +++ b/README.md @@ -1,185 +1,40 @@ -polaris-go -======================================== -Polaris is an operation centre that supports multiple programming languages, with high compatibility to different application framework. Polaris-go is golang SDK for Polaris. - -## Overview - -Polaris-go provide features listed as below: - -* ** Service instance registration, and health check - - Provides API on/offline registration instance information, with regular report to inform caller server's healthy status. - -* ** Service discovery - - Provides multiple API, for users to get a full list of server instance, or get one server instance after route rule filtering and loadbalancing, which can be applied to srevice invocation soon. - -* ** Service circuitbreaking - - Provide API to report the invocation result, and conduct circuit breaker instance/group insolation based on collected data, eventually recover when the system allows. - -* ** Service ratelimiting - - Provides API for applications to conduct quota check and deduction, supports rate limit policies that are based on server level and port. - -## Quick Guide - -### Preconditions - - - Launch Polaris server locally. - - Create services from polaris console - -### Service Instance Registration - -For the entire code instance, please refer to component provider/register's example, the key logics are listed below: -```` -request := &api.InstanceRegisterRequest{} -request.Namespace = namespace -request.Service = service -request.ServiceToken = token -request.Host = ip -request.Port = port -request.SetTTL(2) -resp, err := provider.Register(request) -if nil != err { - log.Fatalf("fail to register instance, err %v", err) -} -log.Printf("success to register instance, id is %s", resp.InstanceID) -```` - -### Service Instance Deregistration - -For the entire code instance, please refer to component provider/deregister's example, the key logics are listed below: -```` -request := &api.InstanceDeRegisterRequest{} -request.Namespace = namespace -request.Service = service -request.ServiceToken = token -request.Host = ip -request.Port = port -err = provider.Deregister(request) -if nil != err { - log.Fatalf("fail to deregister instance, err %v", err) -} -log.Printf("success to deregister instance") -```` - -### Service Instance HeartBeating - -For the entire code instance, please refer to component provider/deregister's example, the key logics are listed below: -```` -hbRequest := &api.InstanceHeartbeatRequest{} -hbRequest.Namespace = namespace -hbRequest.Service = service -hbRequest.Host = ip -hbRequest.Port = port -hbRequest.ServiceToken = token -if err = provider.Heartbeat(hbRequest); nil != err { - log.Printf("fail to heartbeat, error is %v", err) -} else { - log.Printf("success to call heartbeat for index %d", i) -} -```` - -### Service Discovery - -#### Get individual service instance(through service routing and loadbalancing) - -For the entire code instance, please refer to component consumer/getoneinstance's example, the key logics are listed below: -```` -var getInstancesReq *api.GetOneInstanceRequest -getInstancesReq = &api.GetOneInstanceRequest{} -getInstancesReq.Namespace = namespace -getInstancesReq.Service = service -getInstancesReq.SourceService = svcInfo -getInstancesReq.LbPolicy = lbPolicy -getInstancesReq.HashKey = []byte(hashKey) -startTime := time.Now() -getInstResp, err := consumer.GetOneInstance(getInstancesReq) -if nil != err { - log.Fatalf("fail to sync GetOneInstance, err is %v", err) -} -consumeDuration := time.Since(startTime) -log.Printf("success to sync GetOneInstance, count is %d, consume is %v\n", - len(getInstResp.Instances), consumeDuration) -targetInstance := getInstResp.Instances[0] -log.Printf("sync instance is id=%s, address=%s:%d\n", - targetInstance.GetId(), targetInstance.GetHost(), targetInstance.GetPort()) -```` - -#### Get whole list of service instances - -For the entire code instance, please refer to component consumer/getallinstances's example, the key logics are listed below: -```` -var getAllInstancesReq *api.GetAllInstancesRequest -getAllInstancesReq = &api.GetAllInstancesRequest{} -getAllInstancesReq.Namespace = namespace -getAllInstancesReq.Service = service - -getAllInstResp, err := consumer.GetAllInstances(getAllInstancesReq) -if nil != err { - log.Fatalf("fail to sync GetAllInstances, err is %v", err) -} -log.Printf("success to sync GetAllInstances, count is %d, revision is %s\n", len(getAllInstResp.Instances), - getAllInstResp.Revision) -```` - -### Service CircuitBreaking - -For the entire code instance, please refer to component consumer/circuitbreak's example, the key logics are listed below: -```` -//service discovery,pull instance, report invoke result -var getInstancesReq *api.GetOneInstanceRequest -getInstancesReq = &api.GetOneInstanceRequest{} -getInstancesReq.Namespace = namespace -getInstancesReq.Service = service -resp, err := consumer.GetOneInstance(getInstancesReq) -if nil != err { - log.Fatal(err) -} -targetInstance := resp.GetInstances()[0] -addr := fmt.Sprintf("%s:%d", targetInstance.GetHost(), targetInstance.GetPort()) -fmt.Printf("select address is %s\n", addr) -var retStatus model.RetStatus -var retCode int32 -if target == addr { - retStatus = api.RetFail - retCode = 500 -} else { - retStatus = api.RetSuccess - retCode = 200 -} -svcCallResult := &api.ServiceCallResult{} -svcCallResult.SetCalledInstance(targetInstance) -svcCallResult.SetRetStatus(retStatus) -svcCallResult.SetRetCode(retCode) -svcCallResult.SetDelay(30 * time.Millisecond) -err = consumer.UpdateServiceCallResult(svcCallResult) -if nil != err { - log.Fatal(err) -} -```` - -### Service Ratelimiting - -For the entire code instance, please refer to component provider/ratelimit's example, the key logics are listed below: -```` -quotaReq := api.NewQuotaRequest() -quotaReq.SetNamespace(namespace) -quotaReq.SetService(service) -quotaReq.SetLabels(labels) -future, err := limitAPI.GetQuota(quotaReq) -if nil != err { - log.Fatalf("fail to getQuota, err %v", err) -} -resp := future.Get() -if api.QuotaResultOk == resp.Code { - log.Printf("quota result ok") -} else { - log.Printf("quota result fail, info is %s", resp.Info) -} -```` - -## License - +polaris-go +======================================== +Polaris is an operation centre that supports multiple programming languages, with high compatibility to different application framework. Polaris-go is golang SDK for Polaris. + +## Overview + +Polaris-go provide features listed as below: + +* ** Service instance registration, and health check + + Provides API on/offline registration instance information, with regular report to inform caller server's healthy status. + +* ** Service discovery + + Provides multiple API, for users to get a full list of server instance, or get one server instance after route rule filtering and loadbalancing, which can be applied to srevice invocation soon. + +* ** Service circuitbreaking + + Provide API to report the invocation result, and conduct circuit breaker instance/group insolation based on collected data, eventually recover when the system allows. + +* ** Service ratelimiting + + Provides API for applications to conduct quota check and deduction, supports rate limit policies that are based on server level and port. + +## Quick Guide + +### Dependencies + +polaris-go can be referenced by go mod, user can add dependency to go.mod file +``` +github.com/polarismesh/polaris-go v1.0.0 +``` + +### Using API + +API quick start guide,can reference:[QuickStart](sample/quickstart) + +## License + The polaris-go is licensed under the BSD 3-Clause License. Copyright and license information can be found in the file [LICENSE](LICENSE) \ No newline at end of file diff --git a/pkg/config/default.go b/pkg/config/default.go index 11439c0b..d1f146da 100644 --- a/pkg/config/default.go +++ b/pkg/config/default.go @@ -65,7 +65,7 @@ const ( //默认持久化文件有效时间 DefaultPersistAvailableInterval = 60 * time.Second //默认熔断节点检查周期 - DefaultCircuitBreakerCheckPeriod time.Duration = 30 * time.Second + DefaultCircuitBreakerCheckPeriod time.Duration = 10 * time.Second //最低熔断节点检查周期 MinCircuitBreakerCheckPeriod time.Duration = 1 * time.Second //熔断器默认开启与否 diff --git a/pkg/model/service.go b/pkg/model/service.go index 0152cd92..fb6958a4 100644 --- a/pkg/model/service.go +++ b/pkg/model/service.go @@ -90,6 +90,19 @@ const ( Close Status = 3 ) +// String toString method +func (s Status) String() string { + switch s { + case Open: + return "open" + case HalfOpen: + return "half-open" + case Close: + return "close" + } + return "unknown" +} + // HealthCheckStatus 健康探测状态 type HealthCheckStatus int diff --git a/pkg/version/version.go b/pkg/version/version.go index cbe4dfee..df07f98e 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -19,7 +19,7 @@ package version var ( //当前版本号 - Version = "v1.0.0-alpha.0" + Version = "v1.0.0" //客户端类型 ClientType = "polaris-go" ) diff --git a/sample/features/README.md b/sample/features/README.md index c1fcf2d1..971feed6 100644 --- a/sample/features/README.md +++ b/sample/features/README.md @@ -1,5 +1,5 @@ # Polaris Go -## 功能使用 +## 目录说明 提供北极星各功能点详细使用样例 diff --git a/sample/features/activehealthcheck/README.md b/sample/features/activehealthcheck/README.md new file mode 100644 index 00000000..7899f445 --- /dev/null +++ b/sample/features/activehealthcheck/README.md @@ -0,0 +1,73 @@ +# Polaris Go + +## 北极星主动探测功能实例 + +北极星支持主调端触发的主动探测能力,支持两种探测模式 + +- 持续探测:对客户端缓存的所有的服务实例,进行持续探测,探测失败则被熔断,探测成功则半开 + +- 故障时探测:当服务实例被熔断后,进行探测,探测成功则半开 + +支持以下2种探测协议,可同时使用,也可只使用其中一种 + +- HTTP协议:支持针对被调端的HTTP接口进行探测,用户可以指定http path, header等信息 + +- TCP协议:支持tcp connect模式的端口探测 + +## 如何构建 + +直接依赖go mod进行构建 + +- linux/mac构建命令 +``` +go build -o activehealthcheck +``` +- windows构建命令 +``` +go build -o activehealthcheck.exe +``` + +## 如何使用 + +### 创建服务 + +预先通过北极星控制台创建对应的服务,如果是通过本地一键安装包的方式安装,直接在浏览器通过127.0.0.1:8091打开控制台 + +### 修改配置 + +指定北极星服务端地址,需编辑polaris.yaml文件,填入服务端地址 + +``` +global: + serverConnector: + addresses: + - 127.0.0.1:8091 +``` + +### 执行程序 + +直接执行生成的可执行程序 + +- linux/mac运行命令 +``` +./activehealthcheck --service="your service name" --namespace="your namespace name" +``` + +- windows运行命令 +``` +./activehealthcheck.exe --service="your service name" --namespace="your namespace name" +``` + +### 期望结果 + +运行后,最终会打印出每个实例的熔断状态,状态为open,代表的是被熔断,状态为close,代表是可继续提供服务。 + +经过健康检查后,只有一个实例的状态为close,其他都是open + +``` +2021/09/18 16:58:02 instance after activehealthcheck 0 is 127.0.0.1:2003, status is open +2021/09/18 16:58:02 instance after activehealthcheck 1 is 127.0.0.1:2005, status is open +2021/09/18 16:58:02 instance after activehealthcheck 2 is 127.0.0.1:2002, status is open +2021/09/18 16:58:02 instance after activehealthcheck 3 is 127.0.0.1:2004, status is open +2021/09/18 16:58:02 instance after activehealthcheck 4 is 127.0.0.1:2001, status is close +``` \ No newline at end of file diff --git a/sample/features/activehealthcheck/main.go b/sample/features/activehealthcheck/main.go new file mode 100644 index 00000000..5c291201 --- /dev/null +++ b/sample/features/activehealthcheck/main.go @@ -0,0 +1,139 @@ +/** + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package main + +import ( + "flag" + "fmt" + "github.com/polarismesh/polaris-go/api" + "log" + "net/http" + "time" +) + +var ( + namespace string + service string + token string +) + +func initArgs() { + flag.StringVar(&namespace, "namespace", "default", "namespace") + flag.StringVar(&service, "service", "", "service") + flag.StringVar(&token, "token", "", "token") +} + +const ( + host = "127.0.0.1" + startPort = 2001 + instanceCount = 5 +) + +func main() { + initArgs() + flag.Parse() + if len(namespace) == 0 || len(service) == 0 { + log.Print("namespace and service are required") + return + } + consumer, err := api.NewConsumerAPI() + if nil != err { + log.Fatalf("fail to create consumerAPI, err is %v", err) + } + defer consumer.Destroy() + + // share one context with the consumerAPI + provider := api.NewProviderAPIByContext(consumer.SDKContext()) + + log.Printf("start to register instances, count %d", instanceCount) + for i := 0; i < instanceCount; i++ { + registerRequest := &api.InstanceRegisterRequest{} + registerRequest.Service = service + registerRequest.Namespace = namespace + registerRequest.Host = host + registerRequest.Port = startPort + i + registerRequest.ServiceToken = token + registerRequest.SetHealthy(true) + resp, err := provider.Register(registerRequest) + if nil != err { + log.Fatalf("fail to register instance %d, err is %v", i, err) + } + log.Printf("register instance %d response: instanceId %s", i, resp.InstanceID) + } + + log.Printf("start to wait server sync instances") + time.Sleep(5 * time.Second) + + log.Printf("start http health check server") + go func() { + err = startHTTPServer(fmt.Sprintf("%s:%d", host, startPort)) + if nil != err { + log.Fatalf("fail to start http health check server, err is %v", err) + } + }() + + log.Printf("start first time get all instance") + getAllRequest := &api.GetAllInstancesRequest{} + getAllRequest.Namespace = namespace + getAllRequest.Service = service + allInstResp, err := consumer.GetAllInstances(getAllRequest) + if nil != err { + log.Fatalf("fail to getAllInstances, err is %v", err) + } + instances := allInstResp.GetInstances() + if len(instances) > 0 { + for i, instance := range instances { + var statusStr = "close" + if nil != instance.GetCircuitBreakerStatus() { + statusStr = instance.GetCircuitBreakerStatus().GetStatus().String() + } + log.Printf("instance before activehealthcheck %d is %s:%d, status is %s", i, + instance.GetHost(), instance.GetPort(), statusStr) + } + } + + log.Printf("start to health check instances") + time.Sleep(5 * time.Second) + instances = allInstResp.GetInstances() + if len(instances) > 0 { + for i, instance := range instances { + var statusStr = "close" + if nil != instance.GetCircuitBreakerStatus() { + statusStr = instance.GetCircuitBreakerStatus().GetStatus().String() + } + log.Printf("instance after activehealthcheck %d is %s:%d, status is %s", i, + instance.GetHost(), instance.GetPort(), statusStr) + } + } +} + +// startHttpServer 启动一个Http服务 +func startHTTPServer(address string) error { + mux := http.NewServeMux() + mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { + time.Sleep(50 * time.Millisecond) + log.Printf("receive health http detection") + w.WriteHeader(http.StatusOK) + }) + log.Printf("httpserver ready, addr %s", address) + err := http.ListenAndServe(address, mux) + if nil != err { + log.Printf("httpserver err %v", err) + } + return err +} diff --git a/sample/features/activehealthcheck/polaris.yaml b/sample/features/activehealthcheck/polaris.yaml new file mode 100644 index 00000000..ab708b45 --- /dev/null +++ b/sample/features/activehealthcheck/polaris.yaml @@ -0,0 +1,16 @@ +global: + serverConnector: + addresses: + - 127.0.0.1:8091 +consumer: + healthCheck: + when: always + interval: 1s + chain: + - http + plugin: + http: + path: /health + circuitBreaker: + enable: true + checkPeriod: 1s \ No newline at end of file diff --git a/sample/quickstart/README.md b/sample/quickstart/README.md index 7fc2dbcc..38a05a5f 100644 --- a/sample/quickstart/README.md +++ b/sample/quickstart/README.md @@ -1,5 +1,5 @@ # Polaris Go -## 快速接入 +## 目录说明 提供主调端和被调端应用,快速接入北极星的样例 diff --git a/sample/quickstart/consumer/README.md b/sample/quickstart/consumer/README.md index 578dcb75..21df0dda 100644 --- a/sample/quickstart/consumer/README.md +++ b/sample/quickstart/consumer/README.md @@ -23,6 +23,12 @@ go build -o consumer.exe ## 如何使用 +### 创建服务 + +预先通过北极星控制台创建对应的服务,如果是通过本地一键安装包的方式安装,直接在浏览器通过127.0.0.1:8091打开控制台 + +### 修改配置 + 指定北极星服务端地址,需编辑polaris.yaml文件,填入服务端地址 ``` @@ -32,6 +38,8 @@ global: - 127.0.0.1:8091 ``` +### 执行程序 + 直接执行生成的可执行程序 - linux/mac运行命令 diff --git a/sample/quickstart/provider/README.md b/sample/quickstart/provider/README.md index cd024bb9..a0cc6cbe 100644 --- a/sample/quickstart/provider/README.md +++ b/sample/quickstart/provider/README.md @@ -25,6 +25,12 @@ go build -o provider.exe ## 如何使用 +### 创建服务 + +预先通过北极星控制台创建对应的服务,如果是通过本地一键安装包的方式安装,直接在浏览器通过127.0.0.1:8091打开控制台 + +### 修改配置 + 指定北极星服务端地址,需编辑polaris.yaml文件,填入服务端地址 ``` @@ -34,6 +40,8 @@ global: - 127.0.0.1:8091 ``` +### 执行程序 + 直接执行生成的可执行程序 - linux/mac运行命令 diff --git a/test/circuitbreak/healthcheck_suite.go b/test/circuitbreak/healthcheck_suite.go index c4897cf1..26a12b88 100644 --- a/test/circuitbreak/healthcheck_suite.go +++ b/test/circuitbreak/healthcheck_suite.go @@ -200,8 +200,8 @@ func Logic(c *check.C, c.Assert(err, check.IsNil) }() } - // 2s 之后,探测为Health - time.Sleep(2 * time.Second) + // 5s 之后,探测为Health + time.Sleep(5 * time.Second) if checkFlag { c.Assert(localInstanceValue.GetActiveDetectStatus(), check.NotNil) c.Assert(localInstanceValue.GetActiveDetectStatus().GetStatus(), check.Equals, model.Healthy)