Documentation
¶
Index ¶
- type Backend
- type ContainerMapping
- type LoadBalanceStrategy
- type LoadBalancer
- type PortProxy
- type PortProxyManager
- func (ppm *PortProxyManager) GetProxyStats(ctx igoContext.IContext) map[string]interface{}
- func (ppm *PortProxyManager) Shutdown() error
- func (ppm *PortProxyManager) StartPortProxy(ctx igoContext.IContext, publicPort int) error
- func (ppm *PortProxyManager) StopPortProxy(publicPort int) error
- func (ppm *PortProxyManager) UpdatePortProxy(ctx igoContext.IContext, publicPort int) error
- type Service
- func (s *Service) DelContainerMapping(ctx context.IContext, publicPort int) error
- func (s *Service) DeleteService(ctx context.IContext, name string) error
- func (s *Service) DeployOrUpdateService(ctx context.IContext, req *models.ServiceRequest) (*models.Service, error)
- func (s *Service) GetContainerMapping(ctx context.IContext, publicPort int) ([]*ContainerMapping, error)
- func (s *Service) GetService(ctx context.IContext, name string) *models.Service
- func (s *Service) GetServiceStatus(ctx context.IContext, name string) (*models.ServiceStatusResponse, error)
- func (s *Service) ListServices(ctx context.IContext) []*models.Service
- func (s *Service) ScaleService(ctx context.IContext, name string, replicas int) error
- func (s *Service) UpdateService(ctx context.IContext, req *models.ServiceRequest) (*models.Service, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
ContainerMapping *ContainerMapping
Proxy *httputil.ReverseProxy
Active bool
Connections int64
Weight int
LastUsed time.Time
}
Backend 后端服务器信息
type ContainerMapping ¶
type ContainerMapping struct {
PublicPort int `json:"public_port"` // 对外暴露端口
ContainerPort int `json:"container_port"` // 容器映射端口
ContainerID string `json:"container_id"` // 容器ID
ServiceName string `json:"service_name"` // 服务名称
}
ContainerMapping 容器映射信息
type LoadBalanceStrategy ¶
type LoadBalanceStrategy string
LoadBalanceStrategy 负载均衡策略类型
const ( RoundRobin LoadBalanceStrategy = "round_robin" LeastConnections LoadBalanceStrategy = "least_connections" Weighted LoadBalanceStrategy = "weighted" )
type LoadBalancer ¶
type LoadBalancer struct {
// contains filtered or unexported fields
}
LoadBalancer 负载均衡器
func (*LoadBalancer) SelectBackend ¶
func (lb *LoadBalancer) SelectBackend(r *http.Request) *Backend
SelectBackend 选择后端服务器
type PortProxy ¶ added in v1.0.4
type PortProxy struct {
// contains filtered or unexported fields
}
PortProxy 单个端口的代理实例
type PortProxyManager ¶ added in v1.0.4
type PortProxyManager struct {
// contains filtered or unexported fields
}
PortProxyManager 端口代理管理器(轻量化)
func NewPortManager ¶
func NewPortManager(service *Service) *PortProxyManager
NewPortManager 创建端口代理管理器
func (*PortProxyManager) GetProxyStats ¶ added in v1.0.4
func (ppm *PortProxyManager) GetProxyStats(ctx igoContext.IContext) map[string]interface{}
GetProxyStats 获取代理统计信息
func (*PortProxyManager) Shutdown ¶ added in v1.0.4
func (ppm *PortProxyManager) Shutdown() error
Shutdown 关闭所有代理
func (*PortProxyManager) StartPortProxy ¶ added in v1.0.4
func (ppm *PortProxyManager) StartPortProxy(ctx igoContext.IContext, publicPort int) error
StartPortProxy 启动端口代理
func (*PortProxyManager) StopPortProxy ¶ added in v1.0.4
func (ppm *PortProxyManager) StopPortProxy(publicPort int) error
StopPortProxy 停止端口代理
func (*PortProxyManager) UpdatePortProxy ¶ added in v1.0.4
func (ppm *PortProxyManager) UpdatePortProxy(ctx igoContext.IContext, publicPort int) error
UpdatePortProxy 更新端口代理
type Service ¶
type Service struct {
Cache *cache.MemCache
PortManager *PortProxyManager
// contains filtered or unexported fields
}
Service
func (*Service) DelContainerMapping ¶
DelContainerMapping 删除端口映射缓存 当容器被删除或服务停止时调用此方法清理缓存
func (*Service) DeleteService ¶
DeleteService 删除服务
func (*Service) DeployOrUpdateService ¶
func (s *Service) DeployOrUpdateService(ctx context.IContext, req *models.ServiceRequest) (*models.Service, error)
DeployOrUpdateService 部署或更新服务
func (*Service) GetContainerMapping ¶
func (s *Service) GetContainerMapping(ctx context.IContext, publicPort int) ([]*ContainerMapping, error)
GetContainerMapping 获取端口的所有容器映射 缓存未命中时会从 Docker 实时查询并重新构建缓存
func (*Service) GetService ¶
GetService 获取服务详情
func (*Service) GetServiceStatus ¶
func (s *Service) GetServiceStatus(ctx context.IContext, name string) (*models.ServiceStatusResponse, error)
GetServiceStatus 获取服务状态
func (*Service) ListServices ¶
ListServices 列出所有服务
func (*Service) ScaleService ¶
ScaleService 服务扩缩容 - 直接调用dockerclient
func (*Service) UpdateService ¶
func (s *Service) UpdateService(ctx context.IContext, req *models.ServiceRequest) (*models.Service, error)
UpdateService 更新服务 - 实现滚动更新逻辑
Click to show internal directories.
Click to hide internal directories.