Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ailidani committed Feb 5, 2018
1 parent 505843c commit 763c131
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 5 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (c *Client) JSONPut(key Key, value Value) Value {
}

// QuorumGet concurrently read values from majority nodes
func (c *Client) QuorumGet(key Key) Value {
func (c *Client) QuorumGet(key Key) []Value {
c.cid++
out := make(chan Value)
i := 0
Expand All @@ -153,10 +153,11 @@ func (c *Client) QuorumGet(key Key) Value {
for ; i >= 0; i-- {
set.Put(<-out)
}
if set.Size() == 1 {
return set.Get().(Value)
res := make([]Value, 0)
for _, v := range set.Array() {
res = append(res, v.(Value))
}
return nil
return res
}

// QuorumPut concurrently write values to majority of nodes
Expand Down
10 changes: 10 additions & 0 deletions lib/cset.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ func (s *CSet) Size() int {
defer s.RUnlock()
return len(s.data)
}

func (s *CSet) Array() []interface{} {
array := make([]interface{}, 0)
s.RLock()
defer s.RUnlock()
for e := range s.data {
array = append(array, e)
}
return array
}

0 comments on commit 763c131

Please sign in to comment.