diff --git a/kv/client.go b/kv/client.go index 0599f6702..7a00e3166 100644 --- a/kv/client.go +++ b/kv/client.go @@ -90,8 +90,8 @@ func (cfg *Config) RegisterFlagsWithPrefix(flagsPrefix, defaultPrefix string, f // Client is a high-level client for key-value stores (such as Etcd and // Consul) that exposes operations such as CAS and Watch which take callbacks. -// It also deals with serialisation by using a Codec and having a instance of -// the the desired type passed in to methods ala json.Unmarshal. +// It also deals with serialisation by using a Codec and having an instance of +// the desired type passed in to methods ala json.Unmarshal. type Client interface { // List returns a list of keys under the given prefix. Returned keys will // include the prefix. diff --git a/kv/memberlist/memberlist_client.go b/kv/memberlist/memberlist_client.go index e8a94debe..6fc484ccd 100644 --- a/kv/memberlist/memberlist_client.go +++ b/kv/memberlist/memberlist_client.go @@ -72,8 +72,14 @@ func (c *Client) Get(ctx context.Context, key string) (interface{}, error) { } // Delete is part of kv.Client interface. -func (c *Client) Delete(_ context.Context, _ string) error { - return errors.New("memberlist does not support Delete") +func (c *Client) Delete(ctx context.Context, key string) error { + // delete item from kv store + + err := c.awaitKVRunningOrStopping(ctx) + if err != nil { + return err + } + return c.kv.Delete(ctx, c.codec, key) } // CAS is part of kv.Client interface @@ -307,7 +313,7 @@ type Message struct { Changes []string // List of changes in this message (as computed by *this* node). } -// ValueDesc stores the value along with it's codec and local version. +// ValueDesc stores the value along with its codec and local version. type ValueDesc struct { // We store the decoded value here to prevent decoding the entire state for every // update we receive. Whilst the updates are small and fast to decode, @@ -1483,6 +1489,12 @@ func (m *KV) deleteSentReceivedMessages() { m.receivedMessagesSize = 0 } +func (m *KV) Delete(ctx context.Context, codec codec.Codec, key string) error { + return m.CAS(ctx, key, codec, func(in interface{}) (out interface{}, retry bool, err error) { + return nil, true, nil + }) +} + func addMessageToBuffer(msgs []Message, size int, limit int, msg Message) ([]Message, int) { msgs = append(msgs, msg) size += msg.Size diff --git a/kv/memberlist/tcp_transport.go b/kv/memberlist/tcp_transport.go index 751ad1163..d9c1f36c7 100644 --- a/kv/memberlist/tcp_transport.go +++ b/kv/memberlist/tcp_transport.go @@ -351,7 +351,7 @@ func (t *TCPTransport) GetAutoBindPort() int { // FinalAdvertiseAddr is given the user's configured values (which // might be empty) and returns the desired IP and port to advertise to // the rest of the cluster. -// (Copied from memberlist' net_transport.go) +// (Copied from memberlist's net_transport.go) func (t *TCPTransport) FinalAdvertiseAddr(ip string, port int) (net.IP, int, error) { var advertiseAddr net.IP var advertisePort int