code: func shardTxn(c context.Context, shardID int64, cb shardTxnCb) error {
  	return runTxn(c, func(c context.Context) error {
  		sh := shard{ID: shardID}
  		switch err := datastore.Get(c, &sh); {
  		case err == datastore.ErrNoSuchEntity:
  			return err
  		case err != nil:
  			return transient.Tag.Apply(err)
  		case isFinalState(sh.State):
  			return nil // the shard is already marked as done
  		}
  		switch save, err := cb(c, &sh); {
  		case err != nil:
  			return err
  		case !save:
  			return nil
  		default:
  			sh.Updated = clock.Now(c).UTC()
  			return transient.Tag.Apply(datastore.Put(c, &sh))
  		}
  	})
  }
docs: // shardTxn fetches the shard and calls the callback to examine or mutate it.
  //
  // Silently skips finished shards.