MCPcopy Index your code
hub / github.com/uber/aresdb / parseAndGenerateRandomTime

Function parseAndGenerateRandomTime

examples/examples.go:53–68  ·  view source on GitHub ↗
(timeStr string)

Source from the content-addressed store, hash-verified

51}
52
53func parseAndGenerateRandomTime(timeStr string) uint32 {
54 timeStr = strings.TrimSpace(strings.TrimSuffix(strings.TrimPrefix(timeStr, "{"), "}"))
55
56 t, err := strconv.Atoi(timeStr[:len(timeStr)-1])
57 panicIfErr(err)
58
59 unit, ok := unitToSeconds[timeStr[len(timeStr)-1:]]
60 if !ok {
61 panic(fmt.Sprintf("unit %s not supported", timeStr[len(timeStr)-1:]))
62 }
63
64 duration := time.Duration(t) * unit
65 start := now.Add(-duration)
66
67 return uint32(start.Unix() + random.Int63n(int64(duration.Seconds())))
68}
69
70func panicIfErr(err error) {
71 if err != nil {

Callers 1

ingestDataForTableFunction · 0.85

Calls 2

panicIfErrFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected