server

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunServer

func RunServer()

Types

type Env

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

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

func (*Env) CreateRouter

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

CreateRouter initialize router.

func (*Env) ReleaseDeployLock added in v0.8.0

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) ReleaseDeployLockCron added in v0.8.0

func (env *Env) ReleaseDeployLockCron(releaseAfter time.Duration)

ReleaseDeployLockCron is a function that releases a previously set deploy lock after a specified duration and sends a notification to all active WebSocket clients. It first sleeps for the duration specified by the releaseAfter parameter. After the sleep duration has passed, it sets the deployLockSet field of the Env struct to false, indicating that the deploy lock has been released. It then sends an "unlocked" message to all active WebSocket clients using the notifyWebSocketClients function.

func (*Env) SetCron added in v0.8.0

func (env *Env) SetCron(schedules config.LockdownSchedules)

SetCron is a function that sets up cron jobs based on the provided lockdown schedules. It first creates a new cron.Cron instance. Then, for each schedule in the provided schedules, it parses the duration of the schedule and adds a new cron job to the cron.Cron instance. The cron job, when triggered, will call the SetDeployLockCron function with the parsed duration. If there's an error while parsing the duration or adding the cron job, it logs the error and returns. Finally, it starts the cron.Cron instance, which will start triggering the cron jobs at their specified times.

func (*Env) SetDeployLock added in v0.8.0

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) SetDeployLockCron added in v0.8.0

func (env *Env) SetDeployLockCron(duration time.Duration)

SetDeployLockCron is a function that sets a deploy lock and sends a notification to all active WebSocket clients. It first sets the deployLockSet field of the Env struct to true, indicating that a deploy lock is set. It then sends a "locked" message to all active WebSocket clients using the notifyWebSocketClients function. Finally, it starts a new goroutine that will release the deploy lock after a specified duration by calling the ReleaseDeployLockCron function. The duration parameter specifies the duration for which the deploy lock should be set.

func (*Env) StartRouter

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

Jump to

Keyboard shortcuts

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