-
Notifications
You must be signed in to change notification settings - Fork 0
/
infos.go
214 lines (200 loc) · 4.77 KB
/
infos.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package definitions
import (
"sort"
"github.com/Xuanwo/templateutils"
)
type Info struct {
Namespace string
Category string
Name string
Type Type
Description string
// Only infos that declared inside definitions can set global or export as true.
export bool
global bool
}
func (i Info) Global() bool {
return i.global
}
func (i Info) NameForStructField() string {
if i.export {
return templateutils.ToPascal(i.Name)
} else {
return templateutils.ToCamel(i.Name)
}
}
func (i Info) NameForFunctionName() string {
return templateutils.ToPascal(i.Name)
}
func SortInfos(is []Info) []Info {
sort.Slice(is, func(i, j int) bool {
x, y := is[i], is[j]
if x.Namespace != y.Namespace {
return x.Namespace < y.Namespace
}
if x.Category != y.Category {
return x.Category < y.Category
}
return x.Name < y.Name
})
return is
}
var InfosObjectMetaArray = []Info{
{
Name: "append_offset",
Type: Type{Name: "int64"},
Description: "AppendOffset is the offset of the append object.",
},
{
Name: "content_disposition",
Type: Type{Name: "string"},
},
{
Name: "content_length",
Type: Type{Name: "int64"},
},
{
Name: "content_md5",
Type: Type{Name: "string"},
},
{
Name: "content_type",
Type: Type{Name: "string"},
},
{
Name: "etag",
Type: Type{Name: "string"},
},
{
Name: "id",
Type: Type{Name: "string"},
export: true,
Description: `ID is the unique key in storage.
ID SHOULD be an absolute path compatible with the target operating system-defined file paths, or a unique identifier specified by service.`,
},
{
Name: "last_modified",
Type: Type{Package: "time", Name: "Time"},
},
{
Name: "link_target",
Type: Type{Name: "string"},
Description: "LinkTarget is the symlink target for link object.",
},
{
Name: "mode",
Type: Type{Package: "types", Name: "ObjectMode"},
export: true,
},
{
Name: "multipart_id",
Type: Type{Name: "string"},
Description: "MultipartID is the part id of part object.",
},
{
Name: "path",
Type: Type{Name: "string"},
export: true,
Description: `Path is either the absolute path or the relative path towards storage's WorkDir depends on user's input.
Path SHOULD be Unix style.`,
},
{
Name: "system_metadata",
Type: Type{Name: "interface{}"},
Description: "SystemMetadata stores system defined metadata.",
},
{
Name: "user_metadata",
Type: Type{Name: "map[string]string"},
Description: "UserMetadata stores user defined metadata.",
},
}
var InfosStorageMetaArray = []Info{
{
Name: "append_number_maximum",
Type: Type{Name: "int"},
Description: "Max append numbers in append operation.",
},
{
Name: "append_size_maximum",
Type: Type{Name: "int64"},
Description: "Max append size in append operation.",
},
{
Name: "append_total_size_maximum",
Type: Type{Name: "int64"},
Description: "Max append total size in append operation.",
},
{
Name: "copy_size_maximum",
Type: Type{Name: "int64"},
Description: "Maximum size for copy operation.",
},
{
Name: "fetch_size_maximum",
Type: Type{Name: "int64"},
Description: "Maximum size for fetch operation.",
},
{
Name: "location",
Type: Type{Name: "string"},
},
{
Name: "move_size_maximum",
Type: Type{Name: "int64"},
Description: "Maximum size for move operation.",
},
{
Name: "multipart_number_maximum",
Type: Type{Name: "int"},
Description: "Maximum part number in multipart operation.",
},
{
Name: "multipart_size_maximum",
Type: Type{Name: "int64"},
Description: "Maximum part size in multipart operation.",
},
{
Name: "multipart_size_minimum",
Type: Type{Name: "int64"},
Description: "Minimum part size in multipart operation.",
},
{
Name: "name",
Type: Type{Name: "string"},
export: true,
},
{
Name: "system_metadata",
Type: Type{Name: "interface{}"},
Description: "SystemMetadata stores system defined metadata.",
},
{
Name: "work_dir",
Type: Type{Name: "string"},
export: true,
},
{
Name: "write_size_maximum",
Type: Type{Name: "int64"},
Description: "Maximum size for write operation.",
},
{
Name: "service",
Type: Type{Name: "string"},
export: true,
Description: "Service name.",
},
}
func init() {
for k := range InfosObjectMetaArray {
InfosObjectMetaArray[k].Namespace = NamespaceObject
InfosObjectMetaArray[k].Category = CategoryMeta
InfosObjectMetaArray[k].global = true
}
for k := range InfosStorageMetaArray {
InfosStorageMetaArray[k].Namespace = NamespaceStorage
InfosStorageMetaArray[k].Category = CategoryMeta
InfosStorageMetaArray[k].global = true
}
}