mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Added initial job server * Added job server to be ran as part of platform * Added test job to the enterprise repo * Fixed job server not loading license * Renamed job package to jobs * Fixed TE not being buildable * Added JobStatus table to database * Changed fields used by JobStatus * Added APIs to query job status * Added config change listener to server * Added option to run job server from Makefile * Added ability to enable/disable jobs from config * Commented out placeholder for search indexing job * Fixed govet * Removed debug messages and fixed job api init message
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
JOB_TYPE_DATA_RETENTION = "data_retention"
|
|
JOB_TYPE_SEARCH_INDEXING = "search_indexing"
|
|
)
|
|
|
|
type JobStatus struct {
|
|
Id string `json:"id"`
|
|
Type string `json:"type"`
|
|
StartAt int64 `json:"start_at"`
|
|
LastActivityAt int64 `json:"last_activity_at"`
|
|
LastRunStartedAt int64 `json:"last_run_started_at"`
|
|
LastRunCompletedAt int64 `json:"last_run_completed_at"`
|
|
Status string `json:"status"`
|
|
Data map[string]interface{} `json:"data"`
|
|
}
|
|
|
|
func (js *JobStatus) ToJson() string {
|
|
if b, err := json.Marshal(js); err != nil {
|
|
return ""
|
|
} else {
|
|
return string(b)
|
|
}
|
|
}
|
|
|
|
func JobStatusFromJson(data io.Reader) *JobStatus {
|
|
var status JobStatus
|
|
if err := json.NewDecoder(data).Decode(&status); err == nil {
|
|
return &status
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func JobStatusesToJson(statuses []*JobStatus) string {
|
|
if b, err := json.Marshal(statuses); err != nil {
|
|
return ""
|
|
} else {
|
|
return string(b)
|
|
}
|
|
}
|
|
|
|
func JobStatusesFromJson(data io.Reader) []*JobStatus {
|
|
var statuses []*JobStatus
|
|
if err := json.NewDecoder(data).Decode(&statuses); err == nil {
|
|
return statuses
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|