connector

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MulanPSL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcdClient

type EtcdClient struct {
	Client *clientv3.Client
	Prefix string
	Logger *slog.Logger
}

EtcdClient etcd 客户端。

func NewEtcdClient

func NewEtcdClient(cfg *EtcdConfig, logger *slog.Logger) (*EtcdClient, error)

NewEtcdClient 创建 etcd 客户端,支持可选 TLS 连接。

说明:根据配置参数创建 etcd 客户端,支持认证、TLS 连接、CA 证书验证等。 返回值:etcd 客户端实例,或错误信息

func (*EtcdClient) Close

func (e *EtcdClient) Close() error

Close 关闭 etcd 客户端连接。

说明:关闭 etcd 客户端连接,释放资源 返回值:错误信息

type EtcdConfig

type EtcdConfig struct {
	Endpoints          []string      `toml:"endpoints" yaml:"endpoints" json:"endpoints"`
	Prefix             string        `toml:"prefix" yaml:"prefix" json:"prefix"`
	DialTimeout        time.Duration `toml:"dial_timeout" yaml:"dial_timeout" json:"dial_timeout"`
	AuthDisabled       bool          `toml:"auth_disabled" yaml:"auth_disabled" json:"auth_disabled"`
	Username           string        `toml:"username" yaml:"username" json:"username"`
	Password           string        `toml:"password" yaml:"password" json:"password"`
	TLSDisabled        bool          `toml:"tls_disabled" yaml:"tls_disabled" json:"tls_disabled"`
	InsecureSkipVerify bool          `toml:"insecure_skip_verify" yaml:"insecure_skip_verify" json:"insecure_skip_verify"`
	CAFile             string        `toml:"ca_file" yaml:"ca_file" json:"ca_file"`
	CertFile           string        `toml:"cert_file" yaml:"cert_file" json:"cert_file"`
	KeyFile            string        `toml:"key_file" yaml:"key_file" json:"key_file"`
}

EtcdConfig etcd 客户端配置

说明:支持 TOML、YAML、 JSON 三种格式配置

Jump to

Keyboard shortcuts

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