
Loading…
feat(get): get from quorum #866
Merged
+52
−2
Owner
xiang90
commented
bmizerany
commented
LGTM. It agree it needs a warning in the docs.
Owner
yichengq
commented
lgtm. A smoke test for it would be great.
Owner
philips
commented
We need to add documentation for this and figure out what happens in a mixed version cluster.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commits on Jun 23, 2014
-
xiang90 authored
This page is out of date. Refresh to see the latest.
Showing
with
52 additions
and 2 deletions.
- +8 −2 server/v2/get_handler.go
- +1 −0 store/command_factory.go
- +8 −0 store/v2/command_factory.go
- +35 −0 store/v2/get_command.go
10
server/v2/get_handler.go
1
store/command_factory.go
8
store/v2/command_factory.go
35
store/v2/get_command.go
| @@ -0,0 +1,35 @@ | ||
| +package v2 | ||
| + | ||
| +import ( | ||
| + "github.com/coreos/etcd/log" | ||
| + "github.com/coreos/etcd/store" | ||
| + "github.com/coreos/etcd/third_party/github.com/goraft/raft" | ||
| +) | ||
| + | ||
| +func init() { | ||
| + raft.RegisterCommand(&GetCommand{}) | ||
| +} | ||
| + | ||
| +// The GetCommand gets a key from the Store. | ||
| +type GetCommand struct { | ||
| + Key string `json:"key"` | ||
| + Recursive bool `json:"recursive"` | ||
| + Sorted bool `json:sorted` | ||
| +} | ||
| + | ||
| +// The name of the get command in the log | ||
| +func (c *GetCommand) CommandName() string { | ||
| + return "etcd:get" | ||
| +} | ||
| + | ||
| +// Get the key | ||
| +func (c *GetCommand) Apply(context raft.Context) (interface{}, error) { | ||
| + s, _ := context.Server().StateMachine().(store.Store) | ||
| + e, err := s.Get(c.Key, c.Recursive, c.Sorted) | ||
| + | ||
| + if err != nil { | ||
| + log.Debug(err) | ||
| + return nil, err | ||
| + } | ||
| + return e, nil | ||
| +} |
@bmizerany @philips
I do not suggest people to use this function unless they know exactly what they want.
This is just for
linearizabilityin real time order.Indexis a better indication of the actual order of events.Nothing to do with etcd's write consensus/consistency model.