Documentation ¶
Index ¶
- type NacosConfigClient
- func (n NacosConfigClient[T]) DefaultSelectOneHealthyInstanceToExcute(serviceName string, group string, cluster string, payload map[string]string, ...) (*resty.Response, error)
- func (n NacosConfigClient[T]) NaconfigListen(dataId string, group string, f func(namespace, group, dataId, data string))
- func (n NacosConfigClient[T]) ReadConfigFromYml(dataId string, group string, config *T) *T
- func (n NacosConfigClient[T]) RegisterServiceInstance(ip string, port int, serviceName string, weight int, clusterName string, ...)
- func (n NacosConfigClient[T]) SelectOneHealthyInstance(serviceName string, group string, cluster string) (*model.Instance, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NacosConfigClient ¶
type NacosConfigClient[T any] struct { // contains filtered or unexported fields }
func NewNacosConfigClient ¶
func (NacosConfigClient[T]) DefaultSelectOneHealthyInstanceToExcute ¶ added in v0.0.10
func (n NacosConfigClient[T]) DefaultSelectOneHealthyInstanceToExcute(serviceName string, group string, cluster string, payload map[string]string, path string) (*resty.Response, error)
默认调用Post方法,返回resp
func (NacosConfigClient[T]) NaconfigListen ¶
func (n NacosConfigClient[T]) NaconfigListen(dataId string, group string, f func(namespace, group, dataId, data string))
func (NacosConfigClient[T]) ReadConfigFromYml ¶
func (n NacosConfigClient[T]) ReadConfigFromYml(dataId string, group string, config *T) *T
func (NacosConfigClient[T]) RegisterServiceInstance ¶ added in v0.0.4
func (n NacosConfigClient[T]) RegisterServiceInstance(ip string, port int, serviceName string, weight int, clusterName string, group string)
注册服务
func (NacosConfigClient[T]) SelectOneHealthyInstance ¶ added in v0.0.8
func (n NacosConfigClient[T]) SelectOneHealthyInstance(serviceName string, group string, cluster string) (*model.Instance, error)
获取一个健康的实例 * 具体调用
func hello(c *gin.Context) { name := c.Param("name") instance := selectOneHealthyInstance(NamingClient, "server-java") url := fmt.Sprintf("http://%s:%d/hello/%s", instance.Ip, instance.Port, name) resp, _ := http.Get(url) defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) c.String(http.StatusOK, string(body)) }
Click to show internal directories.
Click to hide internal directories.