Documentation
¶
Index ¶
- func BuildKafkaOptions(asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig, password string, ...) ([]kgo.Opt, error)
- func BuildTLSConfig(name string, f TLSFields) (*tls.Config, error)
- func DialDatabase(ctx context.Context, asset *asset_entity.Asset, ...) (*sql.DB, io.Closer, error)
- func DialEtcd(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.EtcdConfig, ...) (*clientv3.Client, io.Closer, error)
- func DialKafka(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig, ...) (*kgo.Client, error)
- func DialMongoDB(ctx context.Context, asset *asset_entity.Asset, ...) (*mongo.Client, io.Closer, error)
- func DialOSS(ctx context.Context, cfg *asset_entity.OSSConfig, secret string) (*minio.Client, error)
- func DialRedis(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.RedisConfig, ...) (*redis.Client, io.Closer, error)
- func GetOrDialEtcd(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.EtcdConfig, ...) (*clientv3.Client, error)
- func GetOrDialOSS(ctx context.Context, assetID int64, cfg *asset_entity.OSSConfig, secret string) (*minio.Client, error)
- func InvalidateEtcd(assetID int64)
- func InvalidateOSS(assetID int64)
- func KafkaConfigFingerprint(asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig) string
- func NormalizeKafkaBrokers(brokers []string) []string
- func ProxyChainDialContext(ctx context.Context, chain *asset_entity.ProxyChainConfig) (func(context.Context, string, string) (net.Conn, error), error)
- func RDPDialContext(ctx context.Context, tunnelID int64, cfg *asset_entity.RDPConfig, ...) (func(ctx context.Context, network, addr string) (net.Conn, error), error)
- type KafkaClientManager
- type MongoClientCloser
- type SSHTunnel
- type TLSFields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildKafkaOptions ¶ added in v1.5.0
func BuildKafkaOptions(asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig, password string, sshPool *sshpool.Pool) ([]kgo.Opt, error)
func BuildTLSConfig ¶ added in v1.5.0
BuildTLSConfig 根据通用 TLS 字段构建 *tls.Config。 name 用于错误消息(例如 "Kafka"、"Redis"),方便用户定位是哪种资产的 TLS 配置出错。
func DialDatabase ¶
func DialDatabase(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.DatabaseConfig, password string, sshPool *sshpool.Pool) (*sql.DB, io.Closer, error)
DialDatabase 创建数据库连接(直连、SSH 隧道或 SOCKS5 代理,隧道优先) password 为已解析的明文密码,cfg.Proxy.Password 为明文,均由调用方负责解密
func DialEtcd ¶ added in v1.7.0
func DialEtcd(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.EtcdConfig, password string, sshPool *sshpool.Pool) (*clientv3.Client, io.Closer, error)
DialEtcd 创建新的 etcd 客户端。可选走 SSH 隧道(仅对第一个 endpoint)或 SOCKS5 代理(隧道优先)。 返回的 tunnel 可为 nil(直连/代理场景)。调用方负责 client.Close() / tunnel.Close()(若非 nil)。
func DialKafka ¶ added in v1.5.0
func DialKafka(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig, password string, sshPool *sshpool.Pool) (*kgo.Client, error)
DialKafka creates a franz-go client and verifies it with Ping.
func DialMongoDB ¶ added in v1.2.0
func DialMongoDB(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.MongoDBConfig, password string, sshPool *sshpool.Pool) (*mongo.Client, io.Closer, error)
DialMongoDB 创建 MongoDB 连接(直连、SSH 隧道或 SOCKS5 代理,隧道优先) password 为已解析的明文密码,cfg.Proxy.Password 为明文,均由调用方负责解密
func DialOSS ¶ added in v1.10.0
func DialOSS(ctx context.Context, cfg *asset_entity.OSSConfig, secret string) (*minio.Client, error)
DialOSS 新建一个 minio 客户端(HTTP 客户端,无需显式 Close)。
func DialRedis ¶
func DialRedis(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.RedisConfig, password string, sshPool *sshpool.Pool) (*redis.Client, io.Closer, error)
DialRedis 创建 Redis 连接(直连、SSH 隧道或 SOCKS5 代理,隧道优先) password 为已解析的明文密码,cfg.Proxy.Password 为明文,均由调用方负责解密
func GetOrDialEtcd ¶ added in v1.7.0
func GetOrDialEtcd(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.EtcdConfig, password string, sshPool *sshpool.Pool) (*clientv3.Client, error)
GetOrDialEtcd 返回缓存中的客户端;未缓存则建立连接并缓存。
func GetOrDialOSS ¶ added in v1.10.0
func GetOrDialOSS(ctx context.Context, assetID int64, cfg *asset_entity.OSSConfig, secret string) (*minio.Client, error)
GetOrDialOSS 返回缓存的 minio 客户端,没有则新建并缓存。
func InvalidateEtcd ¶ added in v1.7.0
func InvalidateEtcd(assetID int64)
InvalidateEtcd 资产更新/删除时调用,强制清理缓存的客户端。
func InvalidateOSS ¶ added in v1.10.0
func InvalidateOSS(assetID int64)
InvalidateOSS 丢弃某资产的缓存客户端(配置更新/删除时调用)。
func KafkaConfigFingerprint ¶ added in v1.5.0
func KafkaConfigFingerprint(asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig) string
func NormalizeKafkaBrokers ¶ added in v1.5.0
func ProxyChainDialContext ¶ added in v1.11.0
func ProxyChainDialContext(ctx context.Context, chain *asset_entity.ProxyChainConfig) (func(context.Context, string, string) (net.Conn, error), error)
ProxyChainDialContext resolves an asset proxy chain into a standard DialContext. A nil function means direct connection. Resolution failures must be returned to the caller instead of being downgraded to a direct connection.
func RDPDialContext ¶ added in v1.10.0
func RDPDialContext(ctx context.Context, tunnelID int64, cfg *asset_entity.RDPConfig, sshPool *sshpool.Pool) (func(ctx context.Context, network, addr string) (net.Conn, error), error)
RDPDialContext 返回 RDP 客户端的自定义拨号函数(隧道 > 代理 > 直连,与其它资产类型一致)。 直连返回 nil,调用方走库默认拨号。cfg.Proxy.Password 为明文,由调用方负责解密。 RDP 的 TLS 在协议内自行协商,这里不做 TLS 包裹;每条隧道连接独立持有 SSH 池引用, 随连接关闭自动释放,无需额外 Closer。
Types ¶
type KafkaClientManager ¶ added in v1.5.0
type KafkaClientManager struct {
// contains filtered or unexported fields
}
KafkaClientManager owns bounded franz-go client reuse for UI/Wails service calls.
func NewKafkaClientManager ¶ added in v1.5.0
func NewKafkaClientManager(sshPool *sshpool.Pool) *KafkaClientManager
func (*KafkaClientManager) Acquire ¶ added in v1.5.0
func (m *KafkaClientManager) Acquire(ctx context.Context, asset *asset_entity.Asset, cfg *asset_entity.KafkaConfig, password string) (*kgo.Client, func(), error)
Acquire 借出一个缓存 client,调用方在使用结束后必须调用返回的 release。 release 内部扣减引用计数;若该 entry 已被驱逐且无人再引用则真正关闭底层 client。
func (*KafkaClientManager) Close ¶ added in v1.5.0
func (m *KafkaClientManager) Close()
func (*KafkaClientManager) CloseAsset ¶ added in v1.5.0
func (m *KafkaClientManager) CloseAsset(assetID int64)
type MongoClientCloser ¶ added in v1.2.0
MongoClientCloser wraps *mongo.Client to satisfy io.Closer.
func (*MongoClientCloser) Close ¶ added in v1.2.0
func (m *MongoClientCloser) Close() error
Close disconnects the underlying MongoDB client.