module
Version:
v1.0.1
Opens a new window with list of versions in this module.
Published: Apr 25, 2021
License: MIT
Opens a new window with license information.
README
¶
go语言的eureka-client
使用方式
package ctx
import (
"gitee.com/gaojh/eureka-client/eureka"
"gitee.com/gaojh/eureka-client/feign"
"sync"
)
type ctx struct {
eurekaClient *eureka.Client
}
var me *ctx
var once sync.Once
func Me() *ctx {
once.Do(func() {
client := eureka.NewClient(&eureka.Config{
DefaultZone: "eureka.url",
App: "eureka.app.name",
Port: 8080,
RenewalIntervalInSecs: 10,
DurationInSecs: 30,
})
me = &ctx{
eurekaClient: client,
}
})
return me
}
func (c *ctx) Start() {
c.eurekaClient.Start()
}
func (c *ctx) FeignClient() *feign.Client {
client := feign.NewClient(me.eurekaClient)
client.Header("clientType", "1")
return client
}
Directories
¶
Click to show internal directories.
Click to hide internal directories.