client: state stubs

This commit is contained in:
Armon Dadgar
2015-08-23 14:12:26 -07:00
parent 1f0877aaa8
commit da43c8fe10

View File

@@ -43,6 +43,13 @@ type RPCHandler interface {
// Config is used to parameterize and configure the behavior of the client
type Config struct {
// DevMode controls if we are in a development mode which
// avoids persistent storage.
DevMode bool
// DataDir is where we store our state
DataDir string
// LogOutput is the destination for logs
LogOutput io.Writer
@@ -103,6 +110,11 @@ func NewClient(config *Config) (*Client, error) {
shutdownCh: make(chan struct{}),
}
// Restore the state
if err := c.restoreState(); err != nil {
return nil, fmt.Errorf("failed to restore state: %v", err)
}
// Setup the node
if err := c.setupNode(); err != nil {
return nil, fmt.Errorf("node setup failed: %v", err)
@@ -223,6 +235,26 @@ func (c *Client) Node() *structs.Node {
return c.config.Node
}
// restoreState is used to restore our state from the data dir
func (c *Client) restoreState() error {
if c.config.DevMode {
return nil
}
// TODO
return nil
}
// saveState is used to snapshot our state into the data dir
func (c *Client) saveState() error {
if c.config.DevMode {
return nil
}
// TODO
return nil
}
// setupNode is used to setup the initial node
func (c *Client) setupNode() error {
node := c.config.Node