Source File
queue.go
Belonging Package
github.com/limanmys/render-engine/app/models
package models
import (
gormjsonb
)
type Operation string
type Status string
const (
OperationReport Operation = "report"
OperationCreate Operation = "create"
OperationUpdate Operation = "update"
OperationInstall Operation = "install"
StatusPending Status = "pending"
StatusProcessing Status = "processing"
StatusDone Status = "done"
StatusFailed Status = "failed"
)
// Queue structure of Queue object
type Queue struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Type Operation `json:"type"`
Status Status `json:"status"`
Data gormjsonb.JSONB `json:"data" gorm:"type:jsonb;index,type:gin"`
Path string `json:"path"`
Error string `json:"error"`
}
func (Queue) () string {
return "queue"
}
// Fill ID of Queue object with UUID beforeCreate
func ( *Queue) ( *gorm.DB) ( error) {
.ID = uuid.New().String()
.Status = StatusPending
.CreatedAt = time.Now()
.UpdatedAt = time.Now()
return
}
func ( *Queue) ( *gorm.DB) ( error) {
.UpdatedAt = time.Now()
return
}
func ( *Queue) ( Status) {
.Status =
database.Connection().Model().Save()
}
func ( *Queue) ( string) {
.Error =
.Status = StatusFailed
database.Connection().Model().Save()
}
func ( *Queue) ( string) {
.Path =
.Status = StatusDone
database.Connection().Model().Save()
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |