Skip to content

Commit

Permalink
ensure a sane sequence of inserved messages
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Jul 30, 2021
1 parent 0555399 commit 82ebf00
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tinode-db/gendb.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func genDb(data *Data) {
str := data.Messages[i%len(data.Messages)]
// Max time between messages is 2 hours, averate - 1 hour, time is increasing as seqId increases
timestamp = timestamp.Add(time.Microsecond * time.Duration(rand.Intn(increment)))
if timestamp.After(now) {
now = timestamp
}

if err = store.Messages.Save(&types.Message{
ObjHeader: types.ObjHeader{CreatedAt: timestamp},
SeqId: seqId,
Expand Down

0 comments on commit 82ebf00

Please sign in to comment.