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:password@127.0.0.1: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:password@127.0.0.1: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