From d804a08744f76234457ad0ebdc63711e0776f8bd Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 31 Mar 2014 11:48:32 -0700 Subject: [PATCH] consul: Adding kvs table to state store --- consul/state_store.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/consul/state_store.go b/consul/state_store.go index cf46b8add..d66c76d92 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -14,7 +14,8 @@ const ( dbNodes = "nodes" dbServices = "services" dbChecks = "checks" - dbMaxMapSize = 128 * 1024 * 1024 // 128MB maximum size + dbKVS = "kvs" + dbMaxMapSize = 512 * 1024 * 1024 // 512MB maximum size ) // The StateStore is responsible for maintaining all the Consul @@ -31,6 +32,7 @@ type StateStore struct { nodeTable *MDBTable serviceTable *MDBTable checkTable *MDBTable + kvsTable *MDBTable tables MDBTables watch map[*MDBTable]*NotifyGroup queryTables map[string]MDBTables @@ -183,8 +185,25 @@ func (s *StateStore) initialize() error { }, } + s.kvsTable = &MDBTable{ + Name: dbKVS, + Indexes: map[string]*MDBIndex{ + "id": &MDBIndex{ + Unique: true, + Fields: []string{"Key"}, + }, + }, + Decoder: func(buf []byte) interface{} { + out := new(structs.DirEntry) + if err := structs.Decode(buf, out); err != nil { + panic(err) + } + return out + }, + } + // Store the set of tables - s.tables = []*MDBTable{s.nodeTable, s.serviceTable, s.checkTable} + s.tables = []*MDBTable{s.nodeTable, s.serviceTable, s.checkTable, s.kvsTable} for _, table := range s.tables { table.Env = s.env table.Encoder = encoder