From 479185694d9d08bb313cce69762fa2255900b7fa Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Tue, 10 Dec 2013 18:19:15 -0800 Subject: [PATCH] Stubs --- consul/fsm.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/consul/fsm.go b/consul/fsm.go index e7e7f0ced..696431ef7 100644 --- a/consul/fsm.go +++ b/consul/fsm.go @@ -33,6 +33,9 @@ func NewFSM() (*consulFSM, error) { } func (c *consulFSM) Apply([]byte) interface{} { + // TODO: Decode + + // TODO: Execute return nil } @@ -41,7 +44,19 @@ func (c *consulFSM) Snapshot() (raft.FSMSnapshot, error) { 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 }