web

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(logger *logrus.Logger) gin.HandlerFunc

ErrorHandler is a middleware that handles errors

func LoggingMiddleware

func LoggingMiddleware(logger *logrus.Logger) gin.HandlerFunc

LoggingMiddleware is a middleware that logs requests

func RecoveryHandler

func RecoveryHandler(logger *logrus.Logger) gin.HandlerFunc

RecoveryHandler is a middleware that recovers from panics

func TemplateFuncs

func TemplateFuncs() template.FuncMap

TemplateFuncs returns a map of template functions

Types

type AppManager

type AppManager interface {
	GetService(ctx context.Context, name string) (*app.Service, error)
	RestartApp(ctx context.Context, id, userID, tenantID string) error
	RestartAppSimple(ctx context.Context, id string) error
	GetContainersByNode(ctx context.Context, nodeID string) ([]api.Container, error)
	GetContainerByID(ctx context.Context, containerID string) (api.Container, error)
	ListServices(ctx context.Context) ([]*app.Service, error)
	DeployApp(ctx context.Context, image, name, service string, volumes []string, env map[string]string) (string, error)
	ScaleApp(ctx context.Context, id string, replicas int, userID ...string) error
	ListTenants(ctx context.Context) ([]app.Tenant, error)
	GetTenant(ctx context.Context, id string) (*app.Tenant, error)
	CreateTenant(ctx context.Context, name, description, owner string) (*app.Tenant, error)
	UpdateTenant(ctx context.Context, id, name, status string) (*app.Tenant, error)
	DeleteTenant(ctx context.Context, id string) error
	ZeroDowntimeDeploy(ctx context.Context, name, image, service string) (string, error)
	GetDeploymentStatus(ctx context.Context, deploymentID string) (*app.DeploymentStatus, error)
	RollbackDeployment(ctx context.Context, deploymentID string) error
}

AppManager defines the interface for application management

type ContainerManager

type ContainerManager interface {
	GetContainers() []*api.Container
	GetContainerStats(ctx context.Context, containerID string) (*api.ContainerStats, error)
	ListContainers(ctx context.Context) ([]api.Container, error)
	ListImages(ctx context.Context) ([]api.Image, error)
}

ContainerManager defines the interface for container management

type ContainerWithStats

type ContainerWithStats struct {
	Container api.Container
	Stats     *api.ContainerStats
}

ContainerWithStats represents a container with its stats

type CreateTenantRequest

type CreateTenantRequest struct {
	Name           string  `json:"name" binding:"required"`
	IsolationLevel string  `json:"isolation_level" binding:"required"`
	Description    string  `json:"description"`
	CPULimit       *uint32 `json:"cpu_limit"`
	MemoryLimit    *uint64 `json:"memory_limit"`
	StorageLimit   *uint64 `json:"storage_limit"`
	MaxContainers  *uint32 `json:"max_containers"`
	MaxServices    *uint32 `json:"max_services"`
	OwnerID        string  `json:"owner_id" binding:"required"`
}

CreateTenantRequest represents a request to create a tenant

type CreateVolumeRequest

type CreateVolumeRequest struct {
	Name string `json:"name" binding:"required"`
}

CreateVolumeRequest represents a request to create a volume

type DeleteTenantRequest

type DeleteTenantRequest struct {
	ID string `json:"id" binding:"required"`
}

DeleteTenantRequest represents a request to delete a tenant

type DeleteVolumeRequest

type DeleteVolumeRequest struct {
	Name string `json:"name" binding:"required"`
}

DeleteVolumeRequest represents a request to delete a volume

type DeployFormParams

type DeployFormParams struct {
	Name    string `form:"name" binding:"required"`
	Image   string `form:"image" binding:"required"`
	Service string `form:"service"`
}

DeployFormParams represents the parameters for the deploy form

type DeployRequest

type DeployRequest struct {
	Name    string            `json:"name" binding:"required"`
	Image   string            `json:"image" binding:"required"`
	Service string            `json:"service"`
	Env     map[string]string `json:"env"`
	Volumes []string          `json:"volumes"`
}

DeployRequest represents a request to deploy an application

type DeploymentStatusResponse

type DeploymentStatusResponse struct {
	ID        string  `json:"id"`
	Status    string  `json:"status"`
	Progress  float32 `json:"progress"`
	Details   string  `json:"details,omitempty"`
	CreatedAt string  `json:"created_at"`
	UpdatedAt string  `json:"updated_at"`
	Completed bool    `json:"completed"`
	Success   bool    `json:"success,omitempty"`
}

DeploymentStatusResponse represents a response for deployment status

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse represents an error response

type MembershipManager

type MembershipManager interface {
}

MembershipManager defines the interface for membership management

type NodeManager

type NodeManager interface {
	GetNodeDetails() ([]node.NodeInfo, error)
	CheckHealth() (bool, error)
	ListNodes(ctx context.Context) ([]interface{}, error)
}

NodeManager defines the interface for node management

type NodeWithContainers

type NodeWithContainers struct {
	ID                string
	Address           string
	CPUAvailable      int64
	MemoryAvailable   int64
	ContainersRunning int
	Containers        []api.Container
}

NodeWithContainers represents a node with its containers

type RestartRequest

type RestartRequest struct {
	Name string `json:"name" binding:"required"`
}

RestartRequest represents a request to restart an application

type ScaleFormParams

type ScaleFormParams struct {
	Replicas int `form:"replicas" binding:"required,min=1"`
}

ScaleFormParams represents the parameters for the scale form

type ScaleRequest

type ScaleRequest struct {
	Name     string `json:"name" binding:"required"`
	Replicas int    `json:"replicas" binding:"required,min=1"`
}

ScaleRequest represents a request to scale an application

type ServiceDiscovery

type ServiceDiscovery interface {
	ListServices() map[string][]service.ServiceEndpoint
	GetServiceURL(ctx context.Context, serviceName string) (string, error)
}

ServiceDiscovery defines the interface for service discovery

type ServiceURLRequest

type ServiceURLRequest struct {
	ServiceName string `json:"service_name" binding:"required"`
}

ServiceURLRequest represents a request to get a service URL

type ServiceWithContainers

type ServiceWithContainers struct {
	Name            string
	Domain          string
	DesiredReplicas int
	CurrentReplicas int
	Containers      []api.Container
}

ServiceWithContainers represents a service with its containers

type StaticHandler

type StaticHandler struct {
	// contains filtered or unexported fields
}

StaticHandler handles static file requests

func NewStaticHandler

func NewStaticHandler(dir string, prefix string) *StaticHandler

NewStaticHandler creates a new static file handler

func (*StaticHandler) Handle

func (h *StaticHandler) Handle(c *gin.Context)

Handle handles static file requests

type StorageManager

type StorageManager interface {
	ListVolumes(ctx context.Context) ([]storage.VolumeStatus, error)
	CreateVolumeSimple(ctx context.Context, name string, size int64) (*storage.VolumeStatus, error)
	DeleteVolumeWithContext(ctx context.Context, id string) error
}

StorageManager defines the interface for storage management

type UpdateTenantRequest

type UpdateTenantRequest struct {
	ID             string  `json:"id" binding:"required"`
	Name           string  `json:"name" binding:"required"`
	IsolationLevel string  `json:"isolation_level" binding:"required"`
	Description    string  `json:"description"`
	CPULimit       *uint32 `json:"cpu_limit"`
	MemoryLimit    *uint64 `json:"memory_limit"`
	StorageLimit   *uint64 `json:"storage_limit"`
	MaxContainers  *uint32 `json:"max_containers"`
	MaxServices    *uint32 `json:"max_services"`
	Status         string  `json:"status" binding:"required"`
}

UpdateTenantRequest represents a request to update a tenant

type VolumeResponse

type VolumeResponse struct {
	Name      string `json:"name"`
	CreatedAt int64  `json:"created_at"`
	Size      uint64 `json:"size"`
}

VolumeResponse represents a volume response

type WebServer

type WebServer struct {
	// contains filtered or unexported fields
}

WebServer represents the web server for the Hivemind UI

func NewWebServer

func NewWebServer(
	appManager AppManager,
	nodeManager NodeManager,
	containerManager ContainerManager,
	serviceDiscovery ServiceDiscovery,
	storageManager StorageManager,
	membershipManager MembershipManager,
	logger *logrus.Logger,
	port uint16,
) (*WebServer, error)

NewWebServer creates a new web server instance

func (*WebServer) ServeCSS

func (ws *WebServer) ServeCSS(c *gin.Context)

ServeCSS serves a CSS file with the given content

func (*WebServer) ServeJS

func (ws *WebServer) ServeJS(c *gin.Context)

ServeJS serves a JavaScript file with the given content

func (*WebServer) ServeStaticFiles

func (ws *WebServer) ServeStaticFiles(dir string, urlPrefix string)

ServeStaticFiles serves static files from the given directory

func (*WebServer) Start

func (ws *WebServer) Start() error

Start starts the web server

func (*WebServer) Stop

func (ws *WebServer) Stop(ctx context.Context) error

Stop stops the web server

type ZeroDowntimeDeployRequest

type ZeroDowntimeDeployRequest struct {
	Name               string  `json:"name" binding:"required"`
	Image              string  `json:"image" binding:"required"`
	Service            string  `json:"service"`
	BatchSize          *uint32 `json:"batch_size"`
	BatchDelay         *uint64 `json:"batch_delay"`
	HealthCheckPath    string  `json:"health_check_path"`
	HealthCheckPort    *uint16 `json:"health_check_port"`
	HealthCheckTimeout *uint64 `json:"health_check_timeout"`
	DrainTimeout       *uint64 `json:"drain_timeout"`
}

ZeroDowntimeDeployRequest represents a request for zero-downtime deployment

type ZeroDowntimeDeployResponse

type ZeroDowntimeDeployResponse struct {
	Success      bool   `json:"success"`
	DeploymentID string `json:"deployment_id,omitempty"`
	Error        string `json:"error,omitempty"`
}

ZeroDowntimeDeployResponse represents a response for zero-downtime deployment

Jump to

Keyboard shortcuts

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