web

package
v0.0.0-...-5b7b456 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFiberConfig

func GetFiberConfig() fiber.Config

func GetFiberLogger

func GetFiberLogger() logger.Config

func GetPayload

func GetPayload(c *fiber.Ctx, payload interface{}) *apierror.APIError

func ValidateStruct

func ValidateStruct(obj interface{}) []*apierror.ValidationError

Types

type HTTPError

type HTTPError struct {
	Code    int    `json:"code" example:"400"`      // The result code
	Message string `json:"message" example:"error"` // The error message
}

type JSONResult

type JSONResult struct {
	Code    int         `json:"code" example:"200"`        // The result code
	Message string      `json:"message" example:"success"` // The result message
	Data    interface{} `json:"data"`                      // The result data
}

type JSONResultCloneJob

type JSONResultCloneJob struct {
	Code    int      `json:"code" example:"200"`        // The result code
	Message string   `json:"message" example:"success"` // The result message
	Job     *job.Job `json:"job"`                       // The job
}

type JSONResultCreateJob

type JSONResultCreateJob struct {
	Code    int      `json:"code" example:"200"`        // The result code
	Message string   `json:"message" example:"success"` // The result message
	Job     *job.Job `json:"job"`                       // The job
}

type JSONResultGetAllJobs

type JSONResultGetAllJobs struct {
	Code    int        `json:"code" example:"200"`        // The result code
	Message string     `json:"message" example:"success"` // The result message
	Jobs    []*job.Job `json:"jobs"`                      // The jobs
}

type JSONResultGetJob

type JSONResultGetJob struct {
	Code    int      `json:"code" example:"200"`        // The result code
	Message string   `json:"message" example:"success"` // The result message
	Job     *job.Job `json:"job"`                       // The job
}

type JSONResultGetLockedResources

type JSONResultGetLockedResources struct {
	Code      int                 `json:"code" example:"200"`        // The result code
	Message   string              `json:"message" example:"success"` // The result message
	Resources job.LockedResources `json:"resources"`                 // The locked resources
}

type JSONResultPullJob

type JSONResultPullJob struct {
	Code    int        `json:"code" example:"200"`        // The result code
	Message string     `json:"message" example:"success"` // The result message
	Jobs    []*job.Job `json:"jobs"`                      // The jobs
}

type JSONResultSuccess

type JSONResultSuccess struct {
	Code    int    `json:"code" example:"200"`        // The result code
	Message string `json:"message" example:"success"` // The result message
}

type WebAPIServer

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

func NewWebAPIServer

func NewWebAPIServer(appConfig *config.Config, fiberConfig fiber.Config, service service.IService, funcShutdownServer func(), funcRestartServer func()) *WebAPIServer

func (*WebAPIServer) AddPrometheus

func (w *WebAPIServer) AddPrometheus(app *fiber.App, notifChan chan service.ServiceEvent)

func (*WebAPIServer) AddRoutes

func (w *WebAPIServer) AddRoutes(app *fiber.App)

func (*WebAPIServer) ApiServerRestart

func (w *WebAPIServer) ApiServerRestart(c *fiber.Ctx) error

ApiServerRestart godoc @Summary Restart server @Description Restart server @ID server-restart @Accept json @Produce json @Tags Admin @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/admin/server/restart [post]

func (*WebAPIServer) ApiServerShutdown

func (w *WebAPIServer) ApiServerShutdown(c *fiber.Ctx) error

ApiServerShutdown godoc @Summary Shutdown server @Description Shutdown server @ID server-shutdown @Accept json @Produce json @Tags Admin @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/admin/server/shutdown [post]

func (*WebAPIServer) CancelJob

func (w *WebAPIServer) CancelJob(c *fiber.Ctx) error

CancelJob godoc @Summary Cancel a running job @Description Cancel a job that is running @ID job-cancel @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/job/{jobuuid}/cancel [post]

func (*WebAPIServer) ChangeVisibilityTimeoutJob

func (w *WebAPIServer) ChangeVisibilityTimeoutJob(c *fiber.Ctx) error

ChangeVisibilityTimeoutJob godoc @Summary Change job visibility timeout @Description Change job visibility timeout @ID job-change-visibility-timeout @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/job/{jobuuid}/visibilitytimeout [post]

func (*WebAPIServer) CloneJob

func (w *WebAPIServer) CloneJob(c *fiber.Ctx) error

CloneJob godoc @Summary Clone job @Description Clone job @ID job-clone @Produce json @Tags Jobs @success 200 {object} web.JSONResultCloneJob{} "successful operation" @Router /api/v1/job/{jobuuid}/clone [post]

func (*WebAPIServer) ComputeMetrics

func (w *WebAPIServer) ComputeMetrics(c *fiber.Ctx) error

ComputeMetrics godoc @Summary Compute server metrics @Description Compute server metrics @ID utils-metrics-compute @Produce plain @Tags Utils @Success 200 {string} string "ok" @Router /computemetrics [post]

func (*WebAPIServer) CreateJob

func (w *WebAPIServer) CreateJob(c *fiber.Ctx) error

CreateJob godoc @Summary Create job @Description Create job @ID job-create @Produce json @Tags Jobs @success 200 {object} web.JSONResultCreateJob{} "successful operation" @Router /api/v1/job/ [post]

func (*WebAPIServer) DeleteAllJobs

func (w *WebAPIServer) DeleteAllJobs(c *fiber.Ctx) error

DeleteAllJobs godoc @Summary Delete all jobs @Description Delete all jobs @ID jobs-delete-all @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/jobs/ [delete]

func (*WebAPIServer) DeleteJob

func (w *WebAPIServer) DeleteJob(c *fiber.Ctx) error

DeleteJob godoc @Summary Delete job @Description Delete job @ID job-delete @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/job/{jobuuid} [delete]

func (*WebAPIServer) FailJob

func (w *WebAPIServer) FailJob(c *fiber.Ctx) error

FailJob godoc @Summary Set job as failed @Description Set job as failed @ID job-set-as-failed @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/job/{jobuuid}/fail [post]

func (*WebAPIServer) GetAllJobs

func (w *WebAPIServer) GetAllJobs(c *fiber.Ctx) error

GetAllJobs godoc @Summary Get all jobs @Description Get all jobs @ID jobs-get-all @Produce json @Tags Jobs @success 200 {object} web.JSONResultGetAllJobs{} "successful operation" @Router /api/v1/jobs/ [get]

func (*WebAPIServer) GetFiberApp

func (w *WebAPIServer) GetFiberApp() *fiber.App

func (*WebAPIServer) GetJob

func (w *WebAPIServer) GetJob(c *fiber.Ctx) error

GetJob godoc @Summary Get a job @Description Get a job @ID job-get @Produce json @Tags Jobs @Param jobuuid path string true "Job UUID" @success 200 {object} web.JSONResultGetJob{} "successful operation" @Failure 400 {object} apierror.APIError "Invalid UUID" @Failure 404 {object} apierror.APIError "Job not found" @Failure 500 {object} apierror.APIError "Invalid job" @Router /api/v1/job/{jobuuid} [get]

func (*WebAPIServer) GetJobUUIDFromParameter

func (w *WebAPIServer) GetJobUUIDFromParameter(c *fiber.Ctx) (job.JobUUID, *apierror.APIError)

func (*WebAPIServer) GetJobUUIDFromQuery

func (w *WebAPIServer) GetJobUUIDFromQuery(c *fiber.Ctx) (*job.JobUUID, *apierror.APIError)

func (*WebAPIServer) GetLockedResources

func (w *WebAPIServer) GetLockedResources(c *fiber.Ctx) error

GetLockedResources godoc @Summary Get locked Resources @Description Get locked Resources @ID resources-get-locked @Produce json @Tags Resources @success 200 {object} web.JSONResultGetLockedResources{} "successful operation" @Router /api/v1/resources/locked [get]

func (*WebAPIServer) GetPullJobRequest

func (w *WebAPIServer) GetPullJobRequest(c *fiber.Ctx) (*service.RequestPullJobs, *apierror.APIError)

func (*WebAPIServer) GetUintParameterFromQuery

func (w *WebAPIServer) GetUintParameterFromQuery(c *fiber.Ctx, name string, defaultValue uint, minValue uint, maxValue uint) (uint, *apierror.APIError)

func (*WebAPIServer) Healthcheck

func (w *WebAPIServer) Healthcheck(c *fiber.Ctx) error

Healthcheck godoc @Summary Healthcheck server @Description Healthcheck server @ID utils-healthcheck @Produce plain @Tags Utils @Success 200 {string} string "ok" @Router /healthcheck [get]

func (*WebAPIServer) Home

func (w *WebAPIServer) Home(c *fiber.Ctx) error

Home godoc @Summary Home page @Description Home page @ID utils-home @Produce plain @Tags Utils @Success 200 {string} string "Welcome to MiniJob!" @Router / [get]

func (*WebAPIServer) Init

func (w *WebAPIServer) Init() error

func (*WebAPIServer) JobsMonitor

func (w *WebAPIServer) JobsMonitor(c *fiber.Ctx) error

JobsMonitor godoc @Summary Monitor jobs @Description Monitor jobs @ID job-monitor @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/jobs/monitor [get]

func (*WebAPIServer) Metrics

func (w *WebAPIServer) Metrics(c *fiber.Ctx) error

Metrics godoc @Summary get server metrics @Description get server metrics @ID utils-metrics-get @Produce plain @Tags Utils @Success 200 {string} string "ok" @Router /metrics [get]

func (*WebAPIServer) Ping

func (w *WebAPIServer) Ping(c *fiber.Ctx) error

Ping godoc @Summary Ping server @Description Ping server @ID utils-ping @Produce plain @Tags Utils @Success 200 {string} string "ok" @Router /ping [get]

func (*WebAPIServer) PullJob

func (w *WebAPIServer) PullJob(c *fiber.Ctx) error

PullJob godoc @Summary Pull one or multiple jobs @Description Pull one or multiple jobs @ID job-pull @Produce json @Tags Jobs @success 200 {object} web.JSONResultPullJob{} "successful operation" @Router /api/v1/job/pull [post]

func (*WebAPIServer) RestartServer

func (w *WebAPIServer) RestartServer()

func (*WebAPIServer) SetJobAsSuccessful

func (w *WebAPIServer) SetJobAsSuccessful(c *fiber.Ctx) error

SetJobAsSuccessful godoc @Summary Set job as successful @Description Set job as successful @ID job-set-as-successful @Produce json @Tags Jobs @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/job/{jobuuid}/succeed [post]

func (*WebAPIServer) ShutdownServer

func (w *WebAPIServer) ShutdownServer()

func (*WebAPIServer) UnlockAllResources

func (w *WebAPIServer) UnlockAllResources(c *fiber.Ctx) error

UnlockAllResources godoc @Summary Unlock all resources @Description Unlock all resources @ID resources-unlock-all @Produce json @Tags Resources @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/resources/unlock [post]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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