We want to use KV in Running and Stopping states.
(ctx context.Context)
| 122 | |
| 123 | // We want to use KV in Running and Stopping states. |
| 124 | func (c *Client) awaitKVRunningOrStopping(ctx context.Context) error { |
| 125 | s := c.kv.State() |
| 126 | switch s { |
| 127 | case services.Running, services.Stopping: |
| 128 | return nil |
| 129 | case services.New, services.Starting: |
| 130 | err := c.kv.AwaitRunning(ctx) |
| 131 | if ns := c.kv.State(); ns == services.Stopping { |
| 132 | return nil |
| 133 | } |
| 134 | return err |
| 135 | default: |
| 136 | return fmt.Errorf("unexpected state: %v", s) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // KVConfig is a config for memberlist.KV |
| 141 | type KVConfig struct { |