server

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

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

Env reference: https://www.alexedwards.net/blog/organising-database-access

func NewEnv

func NewEnv(serverConfig *config.ServerConfig, argo *argocd.Argo, metrics *prometheus.Metrics, updater *argocd.ArgoStatusUpdater) (*Env, error)

NewEnv initializes a new Env instance. This function is used to set up the environment for the application's main operation, including setting configurations, initializing Argo service, and metrics.

func (*Env) CreateRouter

func (env *Env) CreateRouter() *gin.Engine

CreateRouter initialize router.

func (*Env) ReleaseDeployLock

func (env *Env) ReleaseDeployLock(c *gin.Context)

ReleaseDeployLock godoc @Summary Release deploy lock @Description Release deploy lock @Tags frontend @Success 200 {string} string @Router /api/v1/deploy-lock [delete]

func (*Env) SetDeployLock

func (env *Env) SetDeployLock(c *gin.Context)

SetDeployLock godoc @Summary Set deploy lock @Description Set deploy lock @Tags frontend @Success 200 {string} string @Router /api/v1/deploy-lock [post]

func (*Env) Shutdown

func (env *Env) Shutdown()

Shutdown gracefully shuts down the server and all WebSocket connections. This method is safe to call multiple times. It blocks until all WebSocket goroutines have finished or the shutdown timeout is reached. If the timeout is reached, some goroutines may still be running but should exit shortly as they observe the closed shutdownCh. Any long-running WebSocket writes are bounded by their own 5-second timeout in checkConnection.

func (*Env) StartRouter

func (env *Env) StartRouter(router *gin.Engine) *http.Server

StartRouter creates and returns an HTTP server configured with the given router. The caller is responsible for starting the server and handling graceful shutdown.

type Lockdown

type Lockdown struct {
	ManualLock   bool // used to manually lock the system
	OverrideMode bool // used to temporarily disable scheduled lockdowns
	Schedules    []LockdownSchedule
	// contains filtered or unexported fields
}

func NewLockdown

func NewLockdown(schedules string) (*Lockdown, error)

NewLockdown initializes a new Lockdown structure and parses the lockdown schedules if provided. If the schedule parsing is successful, it returns the new Lockdown. Otherwise, it returns an error.

func (*Lockdown) IsLocked

func (l *Lockdown) IsLocked() bool

IsLocked checks if the system is under lockdown. It returns true if either a manual lock is active or if the current time falls within a scheduled lockdown and no override mode is active. Otherwise, it returns false.

func (*Lockdown) Parse

func (l *Lockdown) Parse(schedules string) error

Parse parses the lockdown schedules from a string and stores them in the Lockdown struct.

func (*Lockdown) ReleaseLock

func (l *Lockdown) ReleaseLock()

ReleaseLock cancels the manual lockdown. If a scheduled lockdown is active, it temporarily overrides it for the next 15 minutes. After that period, if the scheduled lockdown is still in progress, the system re-locks.

func (*Lockdown) SetLock

func (l *Lockdown) SetLock()

SetLock immediately places the system into manual lockdown mode. No matter what the scheduled lockdown settings are, once this method is invoked, the system is considered to be under lockdown until manually released.

type LockdownSchedule

type LockdownSchedule struct {
	StartDay  time.Weekday
	StartHour int
	StartMin  int
	EndDay    time.Weekday
	EndHour   int
	EndMin    int
}

type Server

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

func NewServer

func NewServer(serverConfig *config.ServerConfig, reg prometheus.Registerer) (*Server, error)

NewServer creates a new server instance with the given configuration and prometheus registerer.

func (*Server) Run

func (s *Server) Run()

Run starts the HTTP server and handles graceful shutdown on SIGINT/SIGTERM.

Jump to

Keyboard shortcuts

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