This commit is contained in:
Armon Dadgar 2013-12-10 18:19:15 -08:00
parent ac9d2a81ff
commit 479185694d
1 changed files with 16 additions and 1 deletions

View File

@ -33,6 +33,9 @@ func NewFSM() (*consulFSM, error) {
} }
func (c *consulFSM) Apply([]byte) interface{} { func (c *consulFSM) Apply([]byte) interface{} {
// TODO: Decode
// TODO: Execute
return nil return nil
} }
@ -41,7 +44,19 @@ func (c *consulFSM) Snapshot() (raft.FSMSnapshot, error) {
return snap, nil return snap, nil
} }
func (c *consulFSM) Restore(io.ReadCloser) error { func (c *consulFSM) Restore(old io.ReadCloser) error {
defer old.Close()
// Create a new state store
state, err := NewStateStore()
if err != nil {
return err
}
// TODO: Populate the new state
// Do an atomic flip, safe since Apply is not called concurrently
c.state = state
return nil return nil
} }