2025-05-21 04:42:30 +00:00
|
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
"mayfly-go/pkg/model"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type EsInstance struct {
|
|
|
|
|
|
model.Model
|
|
|
|
|
|
|
2025-05-24 16:22:54 +08:00
|
|
|
|
Code string `json:"code" gorm:"size:32;not null;"`
|
|
|
|
|
|
Name string `json:"name" gorm:"size:32;not null;"`
|
2025-10-23 15:29:27 +08:00
|
|
|
|
Protocol string `json:"protocol" gorm:"size:10;not null;"`
|
2025-05-24 16:22:54 +08:00
|
|
|
|
Host string `json:"host" gorm:"size:255;not null;"`
|
|
|
|
|
|
Port int `json:"port"`
|
|
|
|
|
|
Network string `json:"network" gorm:"size:20;"`
|
|
|
|
|
|
Version string `json:"version" gorm:"size:50;"`
|
|
|
|
|
|
Remark *string `json:"remark" gorm:"size:255;"`
|
|
|
|
|
|
SshTunnelMachineId int `json:"sshTunnelMachineId"` // ssh隧道机器id
|
2025-05-21 04:42:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *EsInstance) TableName() string {
|
|
|
|
|
|
return "t_es_instance"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取es连接网络, 若没有使用ssh隧道,则直接返回。否则返回拼接的网络需要注册至指定dial
|
|
|
|
|
|
func (d *EsInstance) GetNetwork() string {
|
|
|
|
|
|
network := d.Network
|
|
|
|
|
|
if d.SshTunnelMachineId <= 0 {
|
|
|
|
|
|
if network == "" {
|
|
|
|
|
|
return "tcp"
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return network
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return fmt.Sprintf("es+ssh:%d", d.SshTunnelMachineId)
|
|
|
|
|
|
}
|