| 48 | } |
| 49 | |
| 50 | func (r *Random) Run(output chan<- *baker.Data) error { |
| 51 | |
| 52 | rand := rand.New(rand.NewSource(r.Cfg.RandSeed)) |
| 53 | |
| 54 | tlen := 15 * 24 * time.Hour |
| 55 | types := []string{"t1", "t2", "t3", "t4"} |
| 56 | |
| 57 | var buf []byte |
| 58 | for i := 0; i < r.Cfg.Records; i++ { |
| 59 | var ll baker.Record |
| 60 | |
| 61 | var t1 [16]byte |
| 62 | rand.Read(t1[:]) |
| 63 | ll.Set(0, []byte(hex.EncodeToString(t1[:]))) |
| 64 | |
| 65 | t2 := time.Date(2015, 8, 1, 15, 0, 0, 0, time.UTC).Add(time.Duration(rand.Int63n(int64(tlen)))) |
| 66 | ll.Set(1, []byte(strconv.Itoa(int(t2.Unix())))) |
| 67 | |
| 68 | t3 := types[rand.Intn(len(types))] |
| 69 | ll.Set(2, []byte(t3)) |
| 70 | |
| 71 | buf = ll.ToText(buf) |
| 72 | buf = append(buf, '\n') |
| 73 | if i%16 == 0 || i == r.Cfg.Records-1 { |
| 74 | output <- &baker.Data{Bytes: buf} |
| 75 | buf = nil |
| 76 | } |
| 77 | } |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | func (r *Random) Stop() {} |
| 82 | func (r *Random) FreeMem(data *baker.Data) {} |