code: func (t *Events) Flush(c context.Context) error {
  	if len(t.ev) == 0 {
  		return nil
  	}
  
  	when := clock.Now(c).UTC()
  	who := string(auth.CurrentIdentity(c))
  
  	entities := make([]*Event, len(t.ev))
  	rows := make([]bigquery.ValueSaver, len(t.ev))
  	for idx, e := range t.ev {
  		// Make events in a batch ordered by time by abusing nanoseconds precision.
  		e.When = google.NewTimestamp(when.Add(time.Duration(idx)))
  		e.Who = who
  		entities[idx] = (&Event{}).FromProto(c, e)
  		rows[idx] = &bq.Row{Message: e}
  	}
  
  	err := parallel.FanOutIn(func(tasks chan<- func() error) {
  		tasks <- func() error { return datastore.Put(c, entities) }
  		tasks <- func() error { return eventsLog.Insert(c, rows...) }
  	})
  	if err != nil {
  		return transient.Tag.Apply(err)
  	}
  
  	t.ev = t.ev[:0]
  	return nil
  }
docs: // Flush sends all pending events to the datastore/bigquery.
  //
  // Returned errors are tagged as transient. On success, clears the pending
  // events queue.