dnacos

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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 NewNacosConfigClient[T any](ip string, port uint64, NamespaceId string, level string) NacosConfigClient[T]

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))
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL