blob: 96ffc2f5253799a695a3690c0c54de1712f561f0 [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -04001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
khenaidoocfee5f42018-07-19 22:47:38 -040016package kvstore
17
18import (
khenaidoocfee5f42018-07-19 22:47:38 -040019 "context"
20 "errors"
khenaidoocfee5f42018-07-19 22:47:38 -040021 "fmt"
yasin sapli5458a1c2021-06-14 22:24:38 +000022 "github.com/opencord/voltha-lib-go/v5/pkg/log"
khenaidoob9203542018-09-17 22:56:37 -040023 v3Client "go.etcd.io/etcd/clientv3"
24 v3rpcTypes "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
khenaidooff4a7bb2021-06-23 13:04:16 -040025 "os"
26 "strconv"
27 "sync"
28 "time"
29)
30
31const (
32 poolCapacityEnvName = "VOLTHA_ETCD_CLIENT_POOL_CAPACITY"
33 maxUsageEnvName = "VOLTHA_ETCD_CLIENT_MAX_USAGE"
34)
35
36const (
37 defaultMaxPoolCapacity = 1000 // Default size of an Etcd Client pool
38 defaultMaxPoolUsage = 100 // Maximum concurrent request an Etcd Client is allowed to process
khenaidoocfee5f42018-07-19 22:47:38 -040039)
40
41// EtcdClient represents the Etcd KV store client
42type EtcdClient struct {
khenaidooff4a7bb2021-06-23 13:04:16 -040043 pool EtcdClientAllocator
44 watchedChannels sync.Map
45 watchedClients map[string]*v3Client.Client
46 watchedClientsLock sync.RWMutex
khenaidoocfee5f42018-07-19 22:47:38 -040047}
48
Himani Chawla27f81212021-04-07 11:37:47 +053049// NewEtcdCustomClient returns a new client for the Etcd KV store allowing
50// the called to specify etcd client configuration
khenaidooff4a7bb2021-06-23 13:04:16 -040051func NewEtcdCustomClient(ctx context.Context, addr string, timeout time.Duration, level log.LogLevel) (*EtcdClient, error) {
52 // Get the capacity and max usage from the environment
53 capacity := defaultMaxPoolCapacity
54 maxUsage := defaultMaxPoolUsage
55 if capacityStr, present := os.LookupEnv(poolCapacityEnvName); present {
56 if val, err := strconv.Atoi(capacityStr); err == nil {
57 capacity = val
58 logger.Infow(ctx, "env-variable-set", log.Fields{"pool-capacity": capacity})
59 } else {
60 logger.Warnw(ctx, "invalid-capacity-value", log.Fields{"error": err, "capacity": capacityStr})
61 }
62 }
63 if maxUsageStr, present := os.LookupEnv(maxUsageEnvName); present {
64 if val, err := strconv.Atoi(maxUsageStr); err == nil {
65 maxUsage = val
66 logger.Infow(ctx, "env-variable-set", log.Fields{"max-usage": maxUsage})
67 } else {
68 logger.Warnw(ctx, "invalid-max-usage-value", log.Fields{"error": err, "max-usage": maxUsageStr})
69 }
khenaidoocfee5f42018-07-19 22:47:38 -040070 }
Stephane Barbariec53a2752019-03-08 17:50:10 -050071
khenaidooff4a7bb2021-06-23 13:04:16 -040072 var err error
Stephane Barbarie260a5632019-02-26 16:12:49 -050073
khenaidooff4a7bb2021-06-23 13:04:16 -040074 pool, err := NewRoundRobinEtcdClientAllocator([]string{addr}, timeout, capacity, maxUsage, level)
75 if err != nil {
76 logger.Errorw(ctx, "failed-to-create-rr-client", log.Fields{
77 "error": err,
78 })
79 }
80
81 logger.Infow(ctx, "etcd-pool-created", log.Fields{"capacity": capacity, "max-usage": maxUsage})
82
83 return &EtcdClient{pool: pool,
84 watchedClients: make(map[string]*v3Client.Client),
85 }, nil
khenaidoocfee5f42018-07-19 22:47:38 -040086}
87
Himani Chawla27f81212021-04-07 11:37:47 +053088// NewEtcdClient returns a new client for the Etcd KV store
89func NewEtcdClient(ctx context.Context, addr string, timeout time.Duration, level log.LogLevel) (*EtcdClient, error) {
khenaidooff4a7bb2021-06-23 13:04:16 -040090 return NewEtcdCustomClient(ctx, addr, timeout, level)
Himani Chawla27f81212021-04-07 11:37:47 +053091}
92
khenaidoob3244212019-08-27 14:32:27 -040093// IsConnectionUp returns whether the connection to the Etcd KV store is up. If a timeout occurs then
94// it is assumed the connection is down or unreachable.
npujar467fe752020-01-16 20:17:45 +053095func (c *EtcdClient) IsConnectionUp(ctx context.Context) bool {
khenaidoob3244212019-08-27 14:32:27 -040096 // Let's try to get a non existent key. If the connection is up then there will be no error returned.
npujar467fe752020-01-16 20:17:45 +053097 if _, err := c.Get(ctx, "non-existent-key"); err != nil {
khenaidoob3244212019-08-27 14:32:27 -040098 return false
99 }
100 return true
101}
102
khenaidoocfee5f42018-07-19 22:47:38 -0400103// List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will
104// wait for a response
npujar467fe752020-01-16 20:17:45 +0530105func (c *EtcdClient) List(ctx context.Context, key string) (map[string]*KVPair, error) {
khenaidooff4a7bb2021-06-23 13:04:16 -0400106 client, err := c.pool.Get(ctx)
107 if err != nil {
108 return nil, err
109 }
110 defer c.pool.Put(client)
111 resp, err := client.Get(ctx, key, v3Client.WithPrefix())
112
khenaidoocfee5f42018-07-19 22:47:38 -0400113 if err != nil {
Rohan Agrawal31f21802020-06-12 05:38:46 +0000114 logger.Error(ctx, err)
khenaidoocfee5f42018-07-19 22:47:38 -0400115 return nil, err
116 }
117 m := make(map[string]*KVPair)
118 for _, ev := range resp.Kvs {
Stephane Barbarieef6650d2019-07-18 12:15:09 -0400119 m[string(ev.Key)] = NewKVPair(string(ev.Key), ev.Value, "", ev.Lease, ev.Version)
khenaidoocfee5f42018-07-19 22:47:38 -0400120 }
121 return m, nil
122}
123
124// Get returns a key-value pair for a given key. Timeout defines how long the function will
125// wait for a response
npujar467fe752020-01-16 20:17:45 +0530126func (c *EtcdClient) Get(ctx context.Context, key string) (*KVPair, error) {
khenaidooff4a7bb2021-06-23 13:04:16 -0400127 client, err := c.pool.Get(ctx)
128 if err != nil {
129 return nil, err
130 }
131 defer c.pool.Put(client)
Stephane Barbarie260a5632019-02-26 16:12:49 -0500132
yasin sapli5458a1c2021-06-14 22:24:38 +0000133 attempt := 0
khenaidooff4a7bb2021-06-23 13:04:16 -0400134
yasin sapli5458a1c2021-06-14 22:24:38 +0000135startLoop:
136 for {
khenaidooff4a7bb2021-06-23 13:04:16 -0400137 resp, err := client.Get(ctx, key)
yasin sapli5458a1c2021-06-14 22:24:38 +0000138 if err != nil {
139 switch err {
140 case context.Canceled:
141 logger.Warnw(ctx, "context-cancelled", log.Fields{"error": err})
142 case context.DeadlineExceeded:
143 logger.Warnw(ctx, "context-deadline-exceeded", log.Fields{"error": err, "context": ctx})
144 case v3rpcTypes.ErrEmptyKey:
145 logger.Warnw(ctx, "etcd-client-error", log.Fields{"error": err})
146 case v3rpcTypes.ErrLeaderChanged,
147 v3rpcTypes.ErrGRPCNoLeader,
148 v3rpcTypes.ErrTimeout,
149 v3rpcTypes.ErrTimeoutDueToLeaderFail,
150 v3rpcTypes.ErrTimeoutDueToConnectionLost:
151 // Retry for these server errors
152 attempt += 1
153 if er := backoff(ctx, attempt); er != nil {
154 logger.Warnw(ctx, "get-retries-failed", log.Fields{"key": key, "error": er, "attempt": attempt})
155 return nil, err
156 }
157 logger.Warnw(ctx, "retrying-get", log.Fields{"key": key, "error": err, "attempt": attempt})
158 goto startLoop
159 default:
160 logger.Warnw(ctx, "etcd-server-error", log.Fields{"error": err})
161 }
162 return nil, err
163 }
npujar467fe752020-01-16 20:17:45 +0530164
yasin sapli5458a1c2021-06-14 22:24:38 +0000165 for _, ev := range resp.Kvs {
166 // Only one value is returned
167 return NewKVPair(string(ev.Key), ev.Value, "", ev.Lease, ev.Version), nil
168 }
169 return nil, nil
khenaidoocfee5f42018-07-19 22:47:38 -0400170 }
khenaidoocfee5f42018-07-19 22:47:38 -0400171}
172
173// Put writes a key-value pair to the KV store. Value can only be a string or []byte since the etcd API
174// accepts only a string as a value for a put operation. Timeout defines how long the function will
175// wait for a response
npujar467fe752020-01-16 20:17:45 +0530176func (c *EtcdClient) Put(ctx context.Context, key string, value interface{}) error {
khenaidoocfee5f42018-07-19 22:47:38 -0400177
178 // Validate that we can convert value to a string as etcd API expects a string
179 var val string
khenaidooff4a7bb2021-06-23 13:04:16 -0400180 var err error
181 if val, err = ToString(value); err != nil {
khenaidoocfee5f42018-07-19 22:47:38 -0400182 return fmt.Errorf("unexpected-type-%T", value)
183 }
184
khenaidooff4a7bb2021-06-23 13:04:16 -0400185 client, err := c.pool.Get(ctx)
186 if err != nil {
187 return err
188 }
189 defer c.pool.Put(client)
190
yasin sapli5458a1c2021-06-14 22:24:38 +0000191 attempt := 0
192startLoop:
193 for {
khenaidooff4a7bb2021-06-23 13:04:16 -0400194 _, err = client.Put(ctx, key, val)
yasin sapli5458a1c2021-06-14 22:24:38 +0000195 if err != nil {
196 switch err {
197 case context.Canceled:
198 logger.Warnw(ctx, "context-cancelled", log.Fields{"error": err})
199 case context.DeadlineExceeded:
200 logger.Warnw(ctx, "context-deadline-exceeded", log.Fields{"error": err, "context": ctx})
201 case v3rpcTypes.ErrEmptyKey:
202 logger.Warnw(ctx, "etcd-client-error", log.Fields{"error": err})
203 case v3rpcTypes.ErrLeaderChanged,
204 v3rpcTypes.ErrGRPCNoLeader,
205 v3rpcTypes.ErrTimeout,
206 v3rpcTypes.ErrTimeoutDueToLeaderFail,
207 v3rpcTypes.ErrTimeoutDueToConnectionLost:
208 // Retry for these server errors
209 attempt += 1
210 if er := backoff(ctx, attempt); er != nil {
211 logger.Warnw(ctx, "put-retries-failed", log.Fields{"key": key, "error": er, "attempt": attempt})
212 return err
213 }
214 logger.Warnw(ctx, "retrying-put", log.Fields{"key": key, "error": err, "attempt": attempt})
215 goto startLoop
216 default:
217 logger.Warnw(ctx, "etcd-server-error", log.Fields{"error": err})
218 }
219 return err
220 }
221 return nil
khenaidoocfee5f42018-07-19 22:47:38 -0400222 }
khenaidoocfee5f42018-07-19 22:47:38 -0400223}
224
225// Delete removes a key from the KV store. Timeout defines how long the function will
226// wait for a response
npujar467fe752020-01-16 20:17:45 +0530227func (c *EtcdClient) Delete(ctx context.Context, key string) error {
khenaidooff4a7bb2021-06-23 13:04:16 -0400228 client, err := c.pool.Get(ctx)
229 if err != nil {
230 return err
231 }
232 defer c.pool.Put(client)
khenaidoocfee5f42018-07-19 22:47:38 -0400233
yasin sapli5458a1c2021-06-14 22:24:38 +0000234 attempt := 0
235startLoop:
236 for {
khenaidooff4a7bb2021-06-23 13:04:16 -0400237 _, err = client.Delete(ctx, key)
yasin sapli5458a1c2021-06-14 22:24:38 +0000238 if err != nil {
239 switch err {
240 case context.Canceled:
241 logger.Warnw(ctx, "context-cancelled", log.Fields{"error": err})
242 case context.DeadlineExceeded:
243 logger.Warnw(ctx, "context-deadline-exceeded", log.Fields{"error": err, "context": ctx})
244 case v3rpcTypes.ErrEmptyKey:
245 logger.Warnw(ctx, "etcd-client-error", log.Fields{"error": err})
246 case v3rpcTypes.ErrLeaderChanged,
247 v3rpcTypes.ErrGRPCNoLeader,
248 v3rpcTypes.ErrTimeout,
249 v3rpcTypes.ErrTimeoutDueToLeaderFail,
250 v3rpcTypes.ErrTimeoutDueToConnectionLost:
251 // Retry for these server errors
252 attempt += 1
253 if er := backoff(ctx, attempt); er != nil {
254 logger.Warnw(ctx, "delete-retries-failed", log.Fields{"key": key, "error": er, "attempt": attempt})
255 return err
256 }
257 logger.Warnw(ctx, "retrying-delete", log.Fields{"key": key, "error": err, "attempt": attempt})
258 goto startLoop
259 default:
260 logger.Warnw(ctx, "etcd-server-error", log.Fields{"error": err})
261 }
262 return err
263 }
264 logger.Debugw(ctx, "key(s)-deleted", log.Fields{"key": key})
265 return nil
khenaidoocfee5f42018-07-19 22:47:38 -0400266 }
khenaidoocfee5f42018-07-19 22:47:38 -0400267}
268
serkant.uluderyac431f2c2021-02-24 17:32:43 +0300269func (c *EtcdClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error {
270
khenaidooff4a7bb2021-06-23 13:04:16 -0400271 client, err := c.pool.Get(ctx)
272 if err != nil {
273 return err
274 }
275 defer c.pool.Put(client)
276
serkant.uluderyac431f2c2021-02-24 17:32:43 +0300277 //delete the prefix
khenaidooff4a7bb2021-06-23 13:04:16 -0400278 if _, err := client.Delete(ctx, prefixKey, v3Client.WithPrefix()); err != nil {
serkant.uluderyac431f2c2021-02-24 17:32:43 +0300279 logger.Errorw(ctx, "failed-to-delete-prefix-key", log.Fields{"key": prefixKey, "error": err})
280 return err
281 }
282 logger.Debugw(ctx, "key(s)-deleted", log.Fields{"key": prefixKey})
283 return nil
284}
285
khenaidoocfee5f42018-07-19 22:47:38 -0400286// Watch provides the watch capability on a given key. It returns a channel onto which the callee needs to
287// listen to receive Events.
Scott Baker0e78ba22020-02-24 17:58:47 -0800288func (c *EtcdClient) Watch(ctx context.Context, key string, withPrefix bool) chan *Event {
khenaidooff4a7bb2021-06-23 13:04:16 -0400289 var err error
290 // Reuse the Etcd client when multiple callees are watching the same key.
291 c.watchedClientsLock.Lock()
292 client, exist := c.watchedClients[key]
293 if !exist {
294 client, err = c.pool.Get(ctx)
295 if err != nil {
296 logger.Errorw(ctx, "failed-to-an-etcd-client", log.Fields{"key": key, "error": err})
297 c.watchedClientsLock.Unlock()
298 return nil
299 }
300 c.watchedClients[key] = client
301 }
302 c.watchedClientsLock.Unlock()
303
304 w := v3Client.NewWatcher(client)
npujar467fe752020-01-16 20:17:45 +0530305 ctx, cancel := context.WithCancel(ctx)
Scott Baker0e78ba22020-02-24 17:58:47 -0800306 var channel v3Client.WatchChan
307 if withPrefix {
308 channel = w.Watch(ctx, key, v3Client.WithPrefix())
309 } else {
310 channel = w.Watch(ctx, key)
311 }
khenaidoocfee5f42018-07-19 22:47:38 -0400312
313 // Create a new channel
314 ch := make(chan *Event, maxClientChannelBufferSize)
315
316 // Keep track of the created channels so they can be closed when required
317 channelMap := make(map[chan *Event]v3Client.Watcher)
318 channelMap[ch] = w
Stephane Barbariec53a2752019-03-08 17:50:10 -0500319 channelMaps := c.addChannelMap(key, channelMap)
320
khenaidooba6b6c42019-08-02 09:11:56 -0400321 // Changing the log field (from channelMaps) as the underlying logger cannot format the map of channels into a
322 // json format.
Rohan Agrawal31f21802020-06-12 05:38:46 +0000323 logger.Debugw(ctx, "watched-channels", log.Fields{"len": len(channelMaps)})
khenaidoocfee5f42018-07-19 22:47:38 -0400324 // Launch a go routine to listen for updates
Rohan Agrawal31f21802020-06-12 05:38:46 +0000325 go c.listenForKeyChange(ctx, channel, ch, cancel)
khenaidoocfee5f42018-07-19 22:47:38 -0400326
327 return ch
328
329}
330
Stephane Barbariec53a2752019-03-08 17:50:10 -0500331func (c *EtcdClient) addChannelMap(key string, channelMap map[chan *Event]v3Client.Watcher) []map[chan *Event]v3Client.Watcher {
332 var channels interface{}
333 var exists bool
334
335 if channels, exists = c.watchedChannels.Load(key); exists {
336 channels = append(channels.([]map[chan *Event]v3Client.Watcher), channelMap)
337 } else {
338 channels = []map[chan *Event]v3Client.Watcher{channelMap}
339 }
340 c.watchedChannels.Store(key, channels)
341
342 return channels.([]map[chan *Event]v3Client.Watcher)
343}
344
345func (c *EtcdClient) removeChannelMap(key string, pos int) []map[chan *Event]v3Client.Watcher {
346 var channels interface{}
347 var exists bool
348
349 if channels, exists = c.watchedChannels.Load(key); exists {
350 channels = append(channels.([]map[chan *Event]v3Client.Watcher)[:pos], channels.([]map[chan *Event]v3Client.Watcher)[pos+1:]...)
351 c.watchedChannels.Store(key, channels)
352 }
353
354 return channels.([]map[chan *Event]v3Client.Watcher)
355}
356
357func (c *EtcdClient) getChannelMaps(key string) ([]map[chan *Event]v3Client.Watcher, bool) {
358 var channels interface{}
359 var exists bool
360
361 channels, exists = c.watchedChannels.Load(key)
362
khenaidoodaefa372019-03-15 14:04:25 -0400363 if channels == nil {
364 return nil, exists
365 }
366
Stephane Barbariec53a2752019-03-08 17:50:10 -0500367 return channels.([]map[chan *Event]v3Client.Watcher), exists
368}
369
khenaidoocfee5f42018-07-19 22:47:38 -0400370// CloseWatch closes a specific watch. Both the key and the channel are required when closing a watch as there
371// may be multiple listeners on the same key. The previously created channel serves as a key
Rohan Agrawal31f21802020-06-12 05:38:46 +0000372func (c *EtcdClient) CloseWatch(ctx context.Context, key string, ch chan *Event) {
khenaidoocfee5f42018-07-19 22:47:38 -0400373 // Get the array of channels mapping
374 var watchedChannels []map[chan *Event]v3Client.Watcher
375 var ok bool
khenaidoocfee5f42018-07-19 22:47:38 -0400376
Stephane Barbariec53a2752019-03-08 17:50:10 -0500377 if watchedChannels, ok = c.getChannelMaps(key); !ok {
Rohan Agrawal31f21802020-06-12 05:38:46 +0000378 logger.Warnw(ctx, "key-has-no-watched-channels", log.Fields{"key": key})
khenaidoocfee5f42018-07-19 22:47:38 -0400379 return
380 }
381 // Look for the channels
382 var pos = -1
383 for i, chMap := range watchedChannels {
384 if t, ok := chMap[ch]; ok {
Rohan Agrawal31f21802020-06-12 05:38:46 +0000385 logger.Debug(ctx, "channel-found")
khenaidoocfee5f42018-07-19 22:47:38 -0400386 // Close the etcd watcher before the client channel. This should close the etcd channel as well
387 if err := t.Close(); err != nil {
Rohan Agrawal31f21802020-06-12 05:38:46 +0000388 logger.Errorw(ctx, "watcher-cannot-be-closed", log.Fields{"key": key, "error": err})
khenaidoocfee5f42018-07-19 22:47:38 -0400389 }
khenaidoocfee5f42018-07-19 22:47:38 -0400390 pos = i
391 break
392 }
393 }
Stephane Barbariec53a2752019-03-08 17:50:10 -0500394
395 channelMaps, _ := c.getChannelMaps(key)
khenaidoocfee5f42018-07-19 22:47:38 -0400396 // Remove that entry if present
397 if pos >= 0 {
Stephane Barbariec53a2752019-03-08 17:50:10 -0500398 channelMaps = c.removeChannelMap(key, pos)
khenaidoocfee5f42018-07-19 22:47:38 -0400399 }
khenaidooff4a7bb2021-06-23 13:04:16 -0400400
401 // If we don't have any keys being watched then return the Etcd client to the pool
402 if len(channelMaps) == 0 {
403 c.watchedClientsLock.Lock()
404 // Sanity
405 if client, ok := c.watchedClients[key]; ok {
406 c.pool.Put(client)
407 delete(c.watchedClients, key)
408 }
409 c.watchedClientsLock.Unlock()
410 }
Rohan Agrawal31f21802020-06-12 05:38:46 +0000411 logger.Infow(ctx, "watcher-channel-exiting", log.Fields{"key": key, "channel": channelMaps})
khenaidoocfee5f42018-07-19 22:47:38 -0400412}
413
Rohan Agrawal31f21802020-06-12 05:38:46 +0000414func (c *EtcdClient) listenForKeyChange(ctx context.Context, channel v3Client.WatchChan, ch chan<- *Event, cancel context.CancelFunc) {
415 logger.Debug(ctx, "start-listening-on-channel ...")
A R Karthick43ba1fb2019-10-03 16:24:21 +0000416 defer cancel()
A R Karthickcbae6232019-10-03 21:37:41 +0000417 defer close(ch)
khenaidoocfee5f42018-07-19 22:47:38 -0400418 for resp := range channel {
419 for _, ev := range resp.Events {
Stephane Barbarieef6650d2019-07-18 12:15:09 -0400420 ch <- NewEvent(getEventType(ev), ev.Kv.Key, ev.Kv.Value, ev.Kv.Version)
khenaidoocfee5f42018-07-19 22:47:38 -0400421 }
422 }
Rohan Agrawal31f21802020-06-12 05:38:46 +0000423 logger.Debug(ctx, "stop-listening-on-channel ...")
khenaidoocfee5f42018-07-19 22:47:38 -0400424}
425
426func getEventType(event *v3Client.Event) int {
427 switch event.Type {
428 case v3Client.EventTypePut:
429 return PUT
430 case v3Client.EventTypeDelete:
431 return DELETE
432 }
433 return UNKNOWN
434}
435
khenaidooff4a7bb2021-06-23 13:04:16 -0400436// Close closes all the connection in the pool store client
Rohan Agrawal31f21802020-06-12 05:38:46 +0000437func (c *EtcdClient) Close(ctx context.Context) {
khenaidooff4a7bb2021-06-23 13:04:16 -0400438 logger.Debug(ctx, "closing-etcd-pool")
439 c.pool.Close(ctx)
khenaidoocfee5f42018-07-19 22:47:38 -0400440}
khenaidoobdcb8e02019-03-06 16:28:56 -0500441
khenaidooff4a7bb2021-06-23 13:04:16 -0400442// The APIs below are not used
443var errUnimplemented = errors.New("deprecated")
444
445// Reserve is deprecated
446func (c *EtcdClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error) {
447 return nil, errUnimplemented
khenaidoobdcb8e02019-03-06 16:28:56 -0500448}
449
khenaidooff4a7bb2021-06-23 13:04:16 -0400450// ReleaseAllReservations is deprecated
451func (c *EtcdClient) ReleaseAllReservations(ctx context.Context) error {
452 return errUnimplemented
khenaidoobdcb8e02019-03-06 16:28:56 -0500453}
454
khenaidooff4a7bb2021-06-23 13:04:16 -0400455// ReleaseReservation is deprecated
456func (c *EtcdClient) ReleaseReservation(ctx context.Context, key string) error {
457 return errUnimplemented
khenaidoobdcb8e02019-03-06 16:28:56 -0500458}
459
khenaidooff4a7bb2021-06-23 13:04:16 -0400460// RenewReservation is deprecated
461func (c *EtcdClient) RenewReservation(ctx context.Context, key string) error {
462 return errUnimplemented
463}
464
465// AcquireLock is deprecated
Neha Sharma7d6f3a92020-04-14 15:26:22 +0000466func (c *EtcdClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error {
khenaidooff4a7bb2021-06-23 13:04:16 -0400467 return errUnimplemented
khenaidoobdcb8e02019-03-06 16:28:56 -0500468}
469
khenaidooff4a7bb2021-06-23 13:04:16 -0400470// ReleaseLock is deprecated
Stephane Barbariec53a2752019-03-08 17:50:10 -0500471func (c *EtcdClient) ReleaseLock(lockName string) error {
khenaidooff4a7bb2021-06-23 13:04:16 -0400472 return errUnimplemented
Stephane Barbariec53a2752019-03-08 17:50:10 -0500473}