This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
model_sync_status.go
72 lines (58 loc) · 1.75 KB
/
model_sync_status.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
72
package bux
import (
"database/sql/driver"
"fmt"
)
// SyncStatus sync status
type SyncStatus string
const (
// SyncStatusPending is when the sync is pending (blocked by other constraints)
SyncStatusPending SyncStatus = statusPending
// SyncStatusReady is when the sync is ready (waiting for workers)
SyncStatusReady SyncStatus = statusReady
// SyncStatusProcessing is when the sync is processing (worker is running task)
SyncStatusProcessing SyncStatus = statusProcessing
// SyncStatusCanceled is when the sync is canceled
SyncStatusCanceled SyncStatus = statusCanceled
// SyncStatusSkipped is when the sync is skipped
SyncStatusSkipped SyncStatus = statusSkipped
// SyncStatusError is when the sync has an error
SyncStatusError SyncStatus = statusError
// SyncStatusComplete is when the sync is complete
SyncStatusComplete SyncStatus = statusComplete
)
// Scan will scan the value into Struct, implements sql.Scanner interface
func (t *SyncStatus) Scan(value interface{}) error {
xType := fmt.Sprintf("%T", value)
var stringValue string
if xType == ValueTypeString {
stringValue = value.(string)
} else {
stringValue = string(value.([]byte))
}
switch stringValue {
case statusPending:
*t = SyncStatusPending
case statusReady:
*t = SyncStatusReady
case statusProcessing:
*t = SyncStatusProcessing
case statusCanceled:
*t = SyncStatusCanceled
case statusError:
*t = SyncStatusError
case statusComplete:
*t = SyncStatusComplete
case statusSkipped:
*t = SyncStatusSkipped
}
return nil
}
// Value return json value, implement driver.Valuer interface
func (t SyncStatus) Value() (driver.Value, error) {
return string(t), nil
}
// String is the string version of the status
func (t SyncStatus) String() string {
return string(t)
}