Categorygithub.com/phpdragon/go-eureka-client
modulepackage
0.0.0-20231101101145-d1cd99d2670f
Repository: https://github.com/phpdragon/go-eureka-client.git
Documentation: pkg.go.dev

# README

go-eureka-client

Description

English | 简体中文

Golang implementation of the unofficial Spring Cloud Eureka client.

Tips: Non-full-features, only some basic and useful features implemented.

Configuration and features

Spring Cloud Eureka Configurations:

ConfigurationSupport
availabilityZones×
serviceUrl
useDnsForFetchingServiceUrls×
preferSameZoneEureka×
filterOnlyUpInstances
registryFetchIntervalSeconds
fetchRegistry
registerWithEureka
shouldUnregisterOnShutdown
instanceEnabledOnInit
renewalIntervalInSecs

go-eureka-client Supported and extended features, refer to list below:

FeatureSupport
RegisterWithEureka
RegistryFetchIntervalSeconds
FetchRegistry
Regular reconnection
Failure to retry
Registration redirection×
HeartbeatIntervals

Eureka server Rest api supported, refer to list below:

OperationHTTP actionSupport
Register new application instancePOST /eureka/v2/apps/appID
De-register application instanceDELETE /eureka/v2/apps/appID/instanceID
Send application instance heartbeatPUT /eureka/v2/apps/appID/instanceID
Query for all instancesGET /eureka/v2/apps
Query for all appID instancesGET /eureka/v2/apps/appID
Query for a specific appID/instanceIDGET /eureka/v2/apps/appID/instanceID
Query for a specific instanceIDGET /eureka/v2/instances/instanceID
Take instance out of servicePUT /eureka/v2/apps/appID/instanceID/status?value=OUT_OF_SERVICE
Move instance back into service (remove override)DELETE /eureka/v2/apps/appID/instanceID/status?value=UP (The value=UP is optional, it is used as a suggestion for the fallback status due to removal of the override)
Update metadataPUT /eureka/v2/apps/appID/instanceID/metadata?key=value
Query for all instances under a particular vip addressGET /eureka/v2/vips/vipAddress
Query for all instances under a particular secure vip addressGET /eureka/v2/svips/svipAddress

Installation

  1. go get github.com/phpdragon/go-eurake-client
  2. import eureka "github.com/phpdragon/go-eureka-client"

Samples

// create eureka client
eurekaClient = eureka.NewClientWithLog("config_sample.yaml", logger.GetLogger())
eurekaClient.Run()
//eurekaClient.Shutdown()

//httpUrl, _ := eurekaClient.GetRealHttpUrl("http://DEMO/action")
//fmt.Println(httpUrl)

// http server
http.HandleFunc("/actuator/info", func(writer http.ResponseWriter, request *http.Request) {
	writeJsonResponse(writer, request, eureka.ActuatorStatus(), true)
})
http.HandleFunc("/actuator/health", func(writer http.ResponseWriter, request *http.Request) {
	writeJsonResponse(writer, request, eureka.ActuatorHealth(), true)
})
http.HandleFunc("/favicon.ico", func(writer http.ResponseWriter, request *http.Request) {
	_, err := writer.Write(gFaviconIco)
	if err != nil {
		logger.Info(err.Error())
		writer.WriteHeader(http.StatusInternalServerError)
		return
	}
})
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
	indexHandler(writer, request, eurekaClient)
})

// start http server
if err := http.ListenAndServe("127.0.0.1:8080", nil); err != nil {
	log.Fatal(err)
}

Contribution

  1. Fork the repository
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Thanks

  1. https://github.com/xuanbo/eureka-client
  2. https://github.com/HikoQiu/go-eureka-client

Use cases

  1. gateway_proxy(转发代理)

Gitee Feature

  1. You can use Readme_XXX.md to support different languages, such as Readme_en.md, Readme_zh.md
  2. Gitee blog blog.gitee.com
  3. Explore open source project https://gitee.com/explore
  4. The most valuable open source project GVP
  5. The manual of Gitee https://gitee.com/help
  6. The most popular members https://gitee.com/gitee-stars/

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author

# Structs

No description provided by the author