diff --git a/api.go b/api.go index 7807bb5..c9a6e9d 100644 --- a/api.go +++ b/api.go @@ -8,6 +8,7 @@ import ( ) // 与eureka服务端rest交互 +// https://github.com/Netflix/eureka/wiki/Eureka-REST-operations // Register 注册实例 // POST /eureka/v2/apps/appID diff --git a/examples/main.go b/examples/main.go index 2b44288..138f8a7 100644 --- a/examples/main.go +++ b/examples/main.go @@ -11,9 +11,11 @@ import ( func main() { // create eureka client client := eureka.NewClient(&eureka.Config{ - DefaultZone: "http://127.0.0.1:8080/eureka/", - App: "golang-example", - Port: 10000, + DefaultZone: "http://127.0.0.1:8080/eureka/", + App: "go-example", + Port: 10000, + RenewalIntervalInSecs: 10, + DurationInSecs: 30, Metadata: map[string]interface{}{ "VERSION": "0.1.0", "NODE_GROUP_ID": 0, @@ -27,7 +29,7 @@ func main() { client.Start() // http server - http.HandleFunc("/services", func(writer http.ResponseWriter, request *http.Request) { + http.HandleFunc("/v1/services", func(writer http.ResponseWriter, request *http.Request) { // full applications from eureka server apps := client.Applications diff --git a/go.mod b/go.mod index 579d785..fb5ff64 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,3 @@ module github.com/xuanbo/eureka-client -require ( - github.com/ArthurHlt/go-eureka-client v1.1.0 - github.com/xuanbo/requests v0.0.1 -) +require github.com/xuanbo/requests v0.0.1 diff --git a/readme-zh.md b/readme-zh.md index 8fe2b73..61aa21c 100644 --- a/readme-zh.md +++ b/readme-zh.md @@ -11,6 +11,8 @@ ## 未完成 +* 当eureka服务端重启后,心跳404时支持重新注册 + * 以delta方式刷新服务列表(增量拉取) 如果delta被禁用或者首次刷新,则使用全量拉取 @@ -31,9 +33,11 @@ import ( func main() { // 创建客户端 client := eureka.NewClient(&eureka.Config{ - DefaultZone: "http://127.0.0.1:8080/eureka/", - App: "golang-example", - Port: 10000, + DefaultZone: "http://127.0.0.1:8080/eureka/", + App: "go-example", + Port: 10000, + RenewalIntervalInSecs: 10, + DurationInSecs: 30, Metadata: map[string]interface{}{ "VERSION": "0.1.0", "NODE_GROUP_ID": 0, diff --git a/readme.md b/readme.md index 5cd0c42..8a84886 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,8 @@ ## Todo +* Re-Register + * Refresh by delta If the delta is disabled or if it is the first time, get all applications @@ -31,10 +33,11 @@ import ( func main() { // create eureka client client := eureka.NewClient(&eureka.Config{ - // DefaultZone: "http://dev.hdsp.hand.com:8000/eureka/", - DefaultZone: "http://127.0.0.1:8080/eureka/", - App: "golang-example", - Port: 10000, + DefaultZone: "http://127.0.0.1:8080/eureka/", + App: "go-example", + Port: 10000, + RenewalIntervalInSecs: 10, + DurationInSecs: 30, Metadata: map[string]interface{}{ "VERSION": "0.1.0", "NODE_GROUP_ID": 0,