client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricsSeconds = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "server",
		Subsystem: "requests",
		Name:      "duration_sec",
		Help:      "server requests duration(sec).",
		Buckets:   []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.250, 0.5, 1},
	}, []string{"kind", "operation"})

	MetricsRequests = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "client",
		Subsystem: "requests",
		Name:      "code_total",
		Help:      "The total number of processed requests",
	}, []string{"kind", "operation", "code", "reason"})
	MetricsLoads = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "server",
		Subsystem: "system",
		Name:      "load_total",
		Help:      "The load of cpu & memory",
	}, []string{"kind", "operation", "code", "reason"})
)
View Source
var (
	ErrInvalidAddr  = errors.New("invalid env of NACOS_HOST or NACOS_PORT")
	ErrCreateClient = func(err error) error { return fmt.Errorf("create nacos client:%w", err) }
)

Functions

func CheckAddrAvailable

func CheckAddrAvailable(addr string, timeout time.Duration) bool

func NewEtcd

func NewEtcd(endpoints []string) (*clientv3.Client, error)

[]string{"127.0.0.1:2379"}

func NewFluentWriteSyncer

func NewFluentWriteSyncer(addr string) (*fluentWriteSyncer, error)

func NewGrpcConn

func NewGrpcConn(discovery registry.Discovery, logger log.Logger, srvName string) (*ggrpc.ClientConn, error)

微服务内部之间的通信,无需安全选项

func NewNacosConfigClient

func NewNacosConfigClient() (config_client.IConfigClient, error)

NewNacosConfigClient 返回作为配置中心的nacos的客户端实例,naco的地址需要通过环境变量配置

func NewNacosNamingClient

func NewNacosNamingClient(endpoint string) (naming_client.INamingClient, error)

NewNacosNamingClient 返回一般nacos客户端

Types

This section is empty.

Jump to

Keyboard shortcuts

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