-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
71 lines (60 loc) · 1.73 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package gogravity
import (
"errors"
"time"
)
// Job Status
const (
QUEUED = "queued"
IN_PROGRESS = "in_progress"
COMPLETED = "completed"
FAILED = "failed"
SKIPPED = "skipped"
)
type job struct {
Uuid string `json:"uuid,omitempty"`
Data interface{} `json:"data,omitempty"`
Retries int `json:"retries,omitempty"`
Priority int `json:"priority,omitempty"`
BackoffUntil string `json:"backoffUntil,omitempty"`
Topic string `json:"topic,omitempty"`
Status string `json:"status,omitempty"`
WorkflowId string `json:"workflowId,omitempty"`
Output interface{} `json:"output,omitempty"`
Error interface{} `json:"error,omitempty"`
CompletedAt time.Time `json:"completedAt,omitempty"`
StartedAt time.Time `json:"startedAt,omitempty"`
}
type jobResponse struct {
Status bool `json:"status,omitempty"`
Data job `json:"data,omitempty"`
}
type jobRequest struct {
Error interface{} `json:"error,omitempty"`
Output interface{} `json:"out,omitempty"`
}
type topicRequest struct {
Uuid string `json:"uuid"`
}
type errorResponse struct {
Status bool `json:"status,omitempty"`
Error struct {
Name string `json:"name,omitempty"`
StatusCode int `json:"statusCode"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
} `json:"error,omitempty"`
}
type apioError struct {
StatusCode int
Message string
}
func (e *apioError) Error() string {
return e.Message
}
func newApioError(statusCode int, message string) *apioError {
return &apioError{StatusCode: statusCode, Message: message}
}
func dummyFunc() error {
return errors.New("gravity worker: called stop function on unstarted worker")
}