import (
...
euregistry "github.com/kitex-contrib/registry-eureka/registry"
"github.com/cloudwego/kitex/server"
"github.com/cloudwego/kitex/pkg/rpcinfo"
...
)
func main() {
...
r = euregistry.NewEurekaRegistry([]string{"http://127.0.0.1:8080/eureka"}, 15*time.Second)
svr := echo.NewServer(new(EchoImpl), server.WithRegistry(r),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "test"}),
)
if err := svr.Run(); err != nil {
log.Println("server stopped with error:", err)
} else {
log.Println("server stopped")
}
...
}
import (
...
"github.com/kitex-contrib/registry-eureka/resolver"
"github.com/cloudwego/kitex/client"
...
)
func main() {
...
r = resolver.NewEurekaResolver([]string{"http://127.0.0.1:8080/eureka"})
client, err := echo.NewClient("echo",
client.WithResolver(r),
)
if err != nil {
log.Fatal(err)
}
...
}
use HTTP Basic Auth
import (
...
euregistry "github.com/kitex-contrib/registry-eureka/registry"
"github.com/cloudwego/kitex/server"
"github.com/cloudwego/kitex/pkg/rpcinfo"
...
)
func main() {
...
r = euregistry.NewEurekaRegistry([]string{"http://username:[email protected]:8080/eureka"}, 15*time.Second)
svr := echo.NewServer(new(EchoImpl), server.WithRegistry(r),
...
}
import (
...
"github.com/kitex-contrib/registry-eureka/resolver"
"github.com/cloudwego/kitex/client"
...
)
func main() {
...
r = resolver.NewEurekaResolver([]string{"http://username:[email protected]:8080/eureka"})
client, err := echo.NewClient("echo",
client.WithResolver(r),
)
...
}
use spring-cloud-starter-netflix-eureka-server
in Java.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
use docker-compose up
and run unit tests.
Eureka client for this project uses fargo ,fargo use github.com/op/go-logging
as logger but does not provide an interface to adjust the log level.
Here are instructions on how to adjust the log level.
import (
...
"github.com/op/go-logging"
"github.com/kitex-contrib/registry-eureka/resolver"
"github.com/cloudwego/kitex/client"
...
)
func main() {
...
// set log level
logging.SetLevel(logging.WARNING, "fargo")
logging.SetLevel(logging.WARNING, "fargo.metadata")
logging.SetLevel(logging.WARNING, "fargo.marshal")
r = resolver.NewEurekaResolver([]string{"http://127.0.0.1:8080/eureka"})
client, err := echo.NewClient("echo",
client.WithResolver(r))
if err != nil {
log.Fatal(err)
}
...
}
See example.
Compatible with eureka server v1.
maintained by: kinggo