func NewStateManager(cfg *config.Config, options ...Option) (StateManager, error) {
	fi, err := os.Stat(cfg.DataDir)
	if err != nil {
		return nil, err
	}
	if !fi.IsDir() {
		return nil, errors.New("State manager DataDir must exist")
	}

	state := &state{
		Data:    make(saveableState),
		Version: ECSDataVersion,
	}
	manager := &basicStateManager{
		statePath: cfg.DataDir,
		state:     state,
	}

	for _, option := range options {
		option(manager)
	}

	manager.platformDependencies = newPlatformDependencies()

	return manager, nil
}
func NewStateManager(cfg *config.Config, options ...Option) (StateManager, error) {
	fi, err := os.Stat(cfg.DataDir)
	if err != nil {
		return nil, err
	}
	if !fi.IsDir() {
		return nil, errors.New("State manager DataDir must exist")
	}

	state := &state{
		Data:    make(saveableState),
		Version: ECSDataVersion,
	}
	manager := &basicStateManager{
		statePath: cfg.DataDir,
		state:     state,
	}

	for _, option := range options {
		option(manager)
	}

	manager.platformDependencies = newPlatformDependencies()

	return manager, nil
}
func NewStateManager ( cfg * config . Config , options ... Option ) ( StateManager , error ) { fi , err := os . Stat ( cfg . DataDir ) if err != nil { return nil , err } if ! fi . IsDir ( ) { return nil , errors . New ( " " ) } state := & state { Data : make ( saveableState ) , Version : ECSDataVersion , } manager := & basicStateManager { statePath : cfg . DataDir , state : state , } for _ , option := range options { option ( manager ) } manager . platformDependencies = newPlatformDependencies ( ) return manager , nil }
// NewStateManager constructs a new StateManager which saves data at the
// location specified in cfg and operates under the given options.
// The returned StateManager will not save more often than every 10 seconds and
// will not reliably return errors with Save, but will log them appropriately.
NewStateManager constructs a new StateManager which saves data at the location specified in cfg and operates under the given options . The returned StateManager will not save more often than every 10 seconds and will not reliably return errors with Save but will log them appropriately .