diff options
author | George Goldberg <george@gberg.me> | 2017-07-07 15:21:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-07 15:21:02 +0100 |
commit | 0495a519499d6cefa289982a94d8f42de541c1f0 (patch) | |
tree | 94b6145daa41ca4d1d4a172f030071076852a09a /model/job_status.go | |
parent | 6e0f5f096986dad11ef182ddb51d4bfb0e558860 (diff) | |
download | chat-0495a519499d6cefa289982a94d8f42de541c1f0.tar.gz chat-0495a519499d6cefa289982a94d8f42de541c1f0.tar.bz2 chat-0495a519499d6cefa289982a94d8f42de541c1f0.zip |
PLT-6916: Redesign the jobs package and Jobserver. (#6733)
This commit redesigns the jobserver to be based around an architecture
of "workers", which carry out jobs of a particular type, and "jobs"
which are a unit of work carried by a particular worker. It also
introduces "schedulers" which are responsible for scheduling jobs of a
particular type automatically (jobs can also be scheduled manually when
apropriate).
Workers may be run many times, either in instances of the platform
binary, or the standalone jobserver binary. In any mattermost cluster,
only one instance of platform OR jobserver must run the schedulers. At
the moment this is controlled by a config variable, but in future will
be controlled through the cluster leader election process.
Diffstat (limited to 'model/job_status.go')
-rw-r--r-- | model/job_status.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/model/job_status.go b/model/job_status.go deleted file mode 100644 index cf490648f..000000000 --- a/model/job_status.go +++ /dev/null @@ -1,59 +0,0 @@ -// 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 - } -} |