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

Method Create

pkg/models/etcd/etcdclient.go:125–141  ·  view source on GitHub ↗
(path string, data []byte)

Source from the content-addressed store, hash-verified

123}
124
125func (c *Client) Create(path string, data []byte) error {
126 c.Lock()
127 defer c.Unlock()
128 if c.closed {
129 return errors.Trace(ErrClosedClient)
130 }
131 cntx, cancel := c.newContext()
132 defer cancel()
133 log.Debugf("etcd create node %s", path)
134 _, err := c.kapi.Set(cntx, path, string(data), &client.SetOptions{PrevExist: client.PrevNoExist})
135 if err != nil {
136 log.Debugf("etcd create node %s failed: %s", path, err)
137 return errors.Trace(err)
138 }
139 log.Debugf("etcd create OK")
140 return nil
141}
142
143func (c *Client) Update(path string, data []byte) error {
144 c.Lock()

Callers

nothing calls this directly

Calls 3

newContextMethod · 0.95
DebugfMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected