Get implements kv.Get.
(ctx context.Context, key string)
| 351 | |
| 352 | // Get implements kv.Get. |
| 353 | func (c *Client) Get(ctx context.Context, key string) (interface{}, error) { |
| 354 | options := &consul.QueryOptions{ |
| 355 | AllowStale: !c.cfg.ConsistentReads, |
| 356 | RequireConsistent: c.cfg.ConsistentReads, |
| 357 | } |
| 358 | kvp, _, err := c.kv.Get(key, options.WithContext(ctx)) |
| 359 | if err != nil { |
| 360 | return nil, err |
| 361 | } else if kvp == nil { |
| 362 | return nil, nil |
| 363 | } |
| 364 | return c.codec.Decode(kvp.Value) |
| 365 | } |
| 366 | |
| 367 | // Delete implements kv.Delete. |
| 368 | func (c *Client) Delete(ctx context.Context, key string) error { |