-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtypes.go
104 lines (94 loc) · 4.92 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package migrate
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type ScanningRequestStatus string
type GenerationRequestStatus string
type ReplicationRequestStatus string
const (
ScanningStatusActive ScanningRequestStatus = "active"
ScanningStatusCompleted ScanningRequestStatus = "completed"
ScanningStatusError ScanningRequestStatus = "error"
ScanningStatusPaused ScanningRequestStatus = "paused"
GenerationStatusActive GenerationRequestStatus = "active"
GenerationStatusError GenerationRequestStatus = "error"
GenerationStatusPaused GenerationRequestStatus = "paused"
GenerationStatusCompleted GenerationRequestStatus = "completed"
GenerationStatusCreated GenerationRequestStatus = "created"
GenerationStatusDAG GenerationRequestStatus = "dag"
ReplicationStatusActive ReplicationRequestStatus = "active"
ReplicationStatusError ReplicationRequestStatus = "error"
ReplicationStatusPaused ReplicationRequestStatus = "paused"
ReplicationStatusCompleted ReplicationRequestStatus = "completed"
)
type ScanningRequest struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Name string `bson:"name"`
Path string `bson:"path"`
OutDir string `bson:"outDir"`
MinSize uint64 `bson:"minSize"`
MaxSize uint64 `bson:"maxSize"`
Status ScanningRequestStatus `bson:"status"`
ErrorMessage string `bson:"errorMessage"`
TmpDir string `bson:"tmpDir"`
SkipInaccessibleFiles bool `bson:"skipInaccessibleFiles"`
}
type GenerationRequest struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
DatasetID string `bson:"datasetId"`
DatasetName string `bson:"datasetName"`
Path string `bson:"path"`
OutDir string `bson:"outDir"`
Index int64 `bson:"index"`
Status GenerationRequestStatus `bson:"status"`
ErrorMessage string `bson:"errorMessage"`
DataCID string `bson:"dataCid"`
CarSize uint64 `bson:"carSize"`
PieceCID string `bson:"pieceCid"`
PieceSize uint64 `bson:"pieceSize"`
FilenameOverride string `bson:"filenameOverride"`
TmpDir string `bson:"tmpDir"`
SkipInaccessibleFiles bool `bson:"skipInaccessibleFiles"`
CreatedAt time.Time `bson:"createdAt"`
}
type OutputFileList struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
GenerationID string `bson:"generationId"`
Index int64 `bson:"index"`
GeneratedFileList []GeneratedFile `bson:"generatedFileList"`
}
type GeneratedFile struct {
Path string `bson:"path"`
Dir bool `bson:"dir"`
CID string `bson:"cid"`
Size uint64 `bson:"size"`
Start uint64 `bson:"start"`
End uint64 `bson:"end"`
}
func (g GeneratedFile) IsComplete() bool {
return g.Start == 0 && (g.End == 0 || g.End == g.Size)
}
type ReplicationRequest struct {
ID primitive.ObjectID `bson:"_id"`
CreatedAt time.Time `bson:"createdAt"`
UpdatedAt time.Time `bson:"updatedAt"`
DatasetID string `bson:"datasetId"`
MaxReplicas int `bson:"maxReplicas"` // targeted replica per piece
StorageProviders string `bson:"storageProviders"` // comma separated SP
Client string `bson:"client"` // deal sent from client address
URLPrefix string `bson:"urlPrefix"`
MaxPrice float64 `bson:"maxPrice"` // unit in Fil
MaxNumberOfDeals uint64 `bson:"maxNumberOfDeals"` // per SP, unlimited if 0
IsVerified bool `bson:"isVerified"`
StartDelay uint64 `bson:"startDelay"` // in epoch
Duration uint64 `bson:"duration"` // in epoch
IsOffline bool `bson:"isOffline"`
Status ReplicationRequestStatus `bson:"status"`
CronSchedule string `bson:"cronSchedule"`
CronMaxDeals uint64 `bson:"cronMaxDeals"`
CronMaxPendingDeals uint64 `bson:"cronMaxPendingDeals"`
FileListPath string `bson:"fileListPath"`
Notes string `bson:"notes"`
ErrorMessage string `bson:"errorMessage"`
}