go-duck-cli 1.4.12 → 1.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/generators/kratos.js
CHANGED
|
@@ -37,12 +37,14 @@ export const generateKratosCode = async (entities, projectRootDir, projectName,
|
|
|
37
37
|
'integer': 'int32',
|
|
38
38
|
'long': 'int64',
|
|
39
39
|
'float': 'float',
|
|
40
|
+
'double': 'double',
|
|
40
41
|
'bigdecimal': 'double',
|
|
41
42
|
'bool': 'bool',
|
|
42
43
|
'boolean': 'bool',
|
|
43
44
|
'localdate': 'string',
|
|
44
45
|
'instant': 'string',
|
|
45
46
|
'datetime': 'string',
|
|
47
|
+
'time': 'string',
|
|
46
48
|
'text': 'string',
|
|
47
49
|
'json': 'string',
|
|
48
50
|
'jsonb': 'string'
|
|
@@ -62,7 +64,8 @@ export const generateKratosCode = async (entities, projectRootDir, projectName,
|
|
|
62
64
|
'int': 'int',
|
|
63
65
|
'integer': 'int',
|
|
64
66
|
'long': 'int64',
|
|
65
|
-
'float': '
|
|
67
|
+
'float': 'float32',
|
|
68
|
+
'double': 'float64',
|
|
66
69
|
'bigdecimal': 'float64',
|
|
67
70
|
'bool': 'bool',
|
|
68
71
|
'boolean': 'bool',
|
|
@@ -82,6 +85,7 @@ export const generateKratosCode = async (entities, projectRootDir, projectName,
|
|
|
82
85
|
'integer': 'int32',
|
|
83
86
|
'long': 'int64',
|
|
84
87
|
'float': 'float32',
|
|
88
|
+
'double': 'float64',
|
|
85
89
|
'bigdecimal': 'float64',
|
|
86
90
|
'json': 'string',
|
|
87
91
|
'jsonb': 'string'
|
package/generators/telemetry.js
CHANGED
|
@@ -262,7 +262,7 @@ func getContainerMemoryLimit() uint64 {
|
|
|
262
262
|
func getCgroupCPUUsageNs() (uint64, error) {
|
|
263
263
|
// try v2
|
|
264
264
|
if data, err := os.ReadFile("/sys/fs/cgroup/cpu.stat"); err == nil {
|
|
265
|
-
lines := strings.Split(string(data), "
|
|
265
|
+
lines := strings.Split(string(data), "\\n")
|
|
266
266
|
for _, line := range lines {
|
|
267
267
|
if strings.HasPrefix(line, "usage_usec") {
|
|
268
268
|
parts := strings.Fields(line)
|
package/package.json
CHANGED
|
@@ -65,10 +65,14 @@ func (s *{{capitalize name}}Service) Create{{capitalize name}}(ctx context.Conte
|
|
|
65
65
|
{{capitalize name}}: parseInstant(req.{{toProtoFieldName name}}),
|
|
66
66
|
{{else if (eq (toLowerCase type) "datetime")}}
|
|
67
67
|
{{capitalize name}}: parseInstant(req.{{toProtoFieldName name}}),
|
|
68
|
+
{{else if (eq (toLowerCase type) "time")}}
|
|
69
|
+
{{capitalize name}}: parseInstant(req.{{toProtoFieldName name}}),
|
|
68
70
|
{{else if (isJson type)}}
|
|
69
71
|
{{capitalize name}}: datatypes.JSON(req.{{toProtoFieldName name}}),
|
|
70
72
|
{{else if isNested}}
|
|
71
73
|
// Nested fields are mapped via JSON for simplicity in gRPC
|
|
74
|
+
{{else if (eq (toLowerCase type) "bigdecimal")}}
|
|
75
|
+
{{capitalize name}}: decimal.NewFromFloat(req.{{toProtoFieldName name}}),
|
|
72
76
|
{{else}}
|
|
73
77
|
{{capitalize name}}: {{#if (toGoCast type)}}{{toGoCast type}}(req.{{toProtoFieldName name}}){{else}}req.{{toProtoFieldName name}}{{/if}},
|
|
74
78
|
{{/if}}
|
|
@@ -179,10 +183,14 @@ func (s *{{capitalize name}}Service) Update{{capitalize name}}(ctx context.Conte
|
|
|
179
183
|
entity.{{capitalize name}} = parseInstant(req.{{toProtoFieldName name}})
|
|
180
184
|
{{else if (eq (toLowerCase type) "datetime")}}
|
|
181
185
|
entity.{{capitalize name}} = parseInstant(req.{{toProtoFieldName name}})
|
|
186
|
+
{{else if (eq (toLowerCase type) "time")}}
|
|
187
|
+
entity.{{capitalize name}} = parseInstant(req.{{toProtoFieldName name}})
|
|
182
188
|
{{else if (isJson type)}}
|
|
183
189
|
entity.{{capitalize name}} = datatypes.JSON(req.{{toProtoFieldName name}})
|
|
184
190
|
{{else if isNested}}
|
|
185
191
|
json.Unmarshal([]byte(req.{{toProtoFieldName name}}), &entity.{{capitalize name}})
|
|
192
|
+
{{else if (eq (toLowerCase type) "bigdecimal")}}
|
|
193
|
+
entity.{{capitalize name}} = decimal.NewFromFloat(req.{{toProtoFieldName name}})
|
|
186
194
|
{{else}}
|
|
187
195
|
entity.{{capitalize name}} = {{#if (toGoCast type)}}{{toGoCast type}}(req.{{toProtoFieldName name}}){{else}}req.{{toProtoFieldName name}}{{/if}}
|
|
188
196
|
{{/if}}
|
|
@@ -394,10 +402,14 @@ func map{{capitalize name}}ToPb(m *models.{{capitalize name}}) *pb.{{capitalize
|
|
|
394
402
|
{{toProtoFieldName name}}: m.{{capitalize name}}.Format(time.RFC3339),
|
|
395
403
|
{{else if (eq (toLowerCase type) "datetime")}}
|
|
396
404
|
{{toProtoFieldName name}}: m.{{capitalize name}}.Format(time.RFC3339),
|
|
405
|
+
{{else if (eq (toLowerCase type) "time")}}
|
|
406
|
+
{{toProtoFieldName name}}: m.{{capitalize name}}.Format(time.RFC3339),
|
|
397
407
|
{{else if (isJson type)}}
|
|
398
408
|
{{toProtoFieldName name}}: string(m.{{capitalize name}}),
|
|
399
409
|
{{else if isNested}}
|
|
400
410
|
{{toProtoFieldName name}}: (func() string { b, _ := json.Marshal(m.{{capitalize name}}); return string(b) })(),
|
|
411
|
+
{{else if (eq (toLowerCase type) "bigdecimal")}}
|
|
412
|
+
{{toProtoFieldName name}}: m.{{capitalize name}}.InexactFloat64(),
|
|
401
413
|
{{else}}
|
|
402
414
|
{{toProtoFieldName name}}: {{#if (toProtoCast type)}}{{toProtoCast type}}(m.{{capitalize name}}){{else}}m.{{capitalize name}}{{/if}},
|
|
403
415
|
{{/if}}
|
|
@@ -65,8 +65,7 @@ func getContainerMemoryLimit() uint64 {
|
|
|
65
65
|
func getCgroupCPUUsageNs() (uint64, error) {
|
|
66
66
|
// try v2
|
|
67
67
|
if data, err := os.ReadFile("/sys/fs/cgroup/cpu.stat"); err == nil {
|
|
68
|
-
lines := strings.Split(string(data), "
|
|
69
|
-
")
|
|
68
|
+
lines := strings.Split(string(data), "\n")
|
|
70
69
|
for _, line := range lines {
|
|
71
70
|
if strings.HasPrefix(line, "usage_usec") {
|
|
72
71
|
parts := strings.Fields(line)
|