MCPcopy
hub / github.com/CodisLabs/codis / List

Method List

pkg/models/etcd/etcdclient.go:203–229  ·  view source on GitHub ↗
(path string, must bool)

Source from the content-addressed store, hash-verified

201}
202
203func (c *Client) List(path string, must bool) ([]string, error) {
204 c.Lock()
205 defer c.Unlock()
206 if c.closed {
207 return nil, errors.Trace(ErrClosedClient)
208 }
209 cntx, cancel := c.newContext()
210 defer cancel()
211 r, err := c.kapi.Get(cntx, path, &client.GetOptions{Quorum: true})
212 switch {
213 case err != nil:
214 if isErrNoNode(err) && !must {
215 return nil, nil
216 }
217 log.Debugf("etcd list node %s failed: %s", path, err)
218 return nil, errors.Trace(err)
219 case !r.Node.Dir:
220 log.Debugf("etcd list node %s failed: not a dir", path)
221 return nil, errors.Trace(ErrNotDir)
222 default:
223 var paths []string
224 for _, node := range r.Node.Nodes {
225 paths = append(paths, node.Key)
226 }
227 return paths, nil
228 }
229}
230
231func (c *Client) CreateEphemeral(path string, data []byte) (<-chan struct{}, error) {
232 c.Lock()

Callers

nothing calls this directly

Calls 4

newContextMethod · 0.95
isErrNoNodeFunction · 0.85
DebugfMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected