code: func (s *Store) txnDispatch(tx *memdb.Txn, idx uint64, ops structs.TxnOps) (structs.TxnResults, structs.TxnErrors) {
  	results := make(structs.TxnResults, 0, len(ops))
  	errors := make(structs.TxnErrors, 0, len(ops))
  	for i, op := range ops {
  		var ret structs.TxnResults
  		var err error
  
  		// Dispatch based on the type of operation.
  		switch {
  		case op.KV != nil:
  			ret, err = s.txnKVS(tx, idx, op.KV)
  		case op.Intention != nil:
  			err = s.txnIntention(tx, idx, op.Intention)
  		case op.Node != nil:
  			ret, err = s.txnNode(tx, idx, op.Node)
  		case op.Service != nil:
  			ret, err = s.txnService(tx, idx, op.Service)
  		case op.Check != nil:
  			ret, err = s.txnCheck(tx, idx, op.Check)
  		default:
  			err = fmt.Errorf("no operation specified")
  		}
  
  		// Accumulate the results.
  		results = append(results, ret...)
  
  		// Capture any error along with the index of the operation that
  		// failed.
  		if err != nil {
  			errors = append(errors, &structs.TxnError{
  				OpIndex: i,
  				What:    err.Error(),
  			})
  		}
  	}
  
  	if len(errors) > 0 {
  		return nil, errors
  	}
  
  	return results, nil
  }
docs: // txnDispatch runs the given operations inside the state store transaction.