From 6e51251cc1036b553e15a1db5973453d2528c706 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 31 Mar 2014 11:47:10 -0700 Subject: [PATCH] consul: Adding new directory structs for KVS --- consul/structs/structs.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/consul/structs/structs.go b/consul/structs/structs.go index 5b32320f28..93b66c25e0 100644 --- a/consul/structs/structs.go +++ b/consul/structs/structs.go @@ -172,6 +172,33 @@ type IndexedCheckServiceNodes struct { Nodes CheckServiceNodes } +// DirEntry is used to represent a directory entry. This is +// used for values in our Key-Value store. +type DirEntry struct { + CreateIndex uint64 + ModifyIndex uint64 + Key string + Flags uint64 + Value []byte +} +type DirEntries []*DirEntry + +type KVSOp string + +const ( + KVSSet KVSOp = "set" + KVSGet = "get" // Key must match + KVSList = "list" // Key is only a prefix + KVSDelete = "delete" + KVSCAS = "cas" // Check-and-set +) + +// KVSRequest is used to operate on the Key-Value store +type KVSRequest struct { + Op KVSOp // Which operation are we performing + DirEnt DirEntry // Which directory entry +} + // Decode is used to decode a MsgPack encoded object func Decode(buf []byte, out interface{}) error { var handle codec.MsgpackHandle