code: func New(gc *state.TombstoneGC, logOutput io.Writer) (*FSM, error) {
  	stateNew, err := state.NewStateStore(gc)
  	if err != nil {
  		return nil, err
  	}
  
  	fsm := &FSM{
  		logOutput: logOutput,
  		logger:    log.New(logOutput, "", log.LstdFlags),
  		apply:     make(map[structs.MessageType]command),
  		state:     stateNew,
  		gc:        gc,
  	}
  
  	// Build out the apply dispatch table based on the registered commands.
  	for msg, fn := range commands {
  		thisFn := fn
  		fsm.apply[msg] = func(buf []byte, index uint64) interface{} {
  			return thisFn(fsm, buf, index)
  		}
  	}
  
  	return fsm, nil
  }
docs: // New is used to construct a new FSM with a blank state.