Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1017 Bytes

File metadata and controls

52 lines (38 loc) · 1017 Bytes

go-eureka-client

go-eureka-client

Eureka client for Go projects for fetching all registered application in Eureka or fetching any available instance IP by application's name.

How to use

Import the package

     go get github.com/oneils/go-eureka-client

Create Eureka client by specifying http client and Eureka server's URL.

   client := http.Client{Timeout: 1 * time.Second}
    c := eureka.NewClient(&client, eurekaServer.URL+"/eureka/apps")

Import the package

    import (
		"github.com/oneils/go-eureka-client/pkg/eureka"
)

Fetch all Eureka applications

   apps, err := c.FetchAll()
   if err != nil {
       log.Fatal(err)
   }
   for _, app := range apps {
       fmt.Println(app.Name)
   }

Fetch Application IP by Application name

   app, err := c.FetchIPAddress("my-app")
   if err != nil {
       log.Fatal(err)
   }
   fmt.Println(app.IPAddr)