| 99 | } |
| 100 | |
| 101 | func (m *mockKV) Put(p *consul.KVPair, _ *consul.WriteOptions) (*consul.WriteMeta, error) { |
| 102 | m.mtx.Lock() |
| 103 | defer m.mtx.Unlock() |
| 104 | |
| 105 | m.current++ |
| 106 | existing, ok := m.kvps[p.Key] |
| 107 | if ok { |
| 108 | existing.Value = p.Value |
| 109 | existing.ModifyIndex = m.current |
| 110 | } else { |
| 111 | m.kvps[p.Key] = &consul.KVPair{ |
| 112 | Key: p.Key, |
| 113 | Value: p.Value, |
| 114 | CreateIndex: m.current, |
| 115 | ModifyIndex: m.current, |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | m.cond.Broadcast() |
| 120 | |
| 121 | level.Debug(m.logger).Log("msg", "Put", "key", p.Key, "value", fmt.Sprintf("%.40q", p.Value), "modify_index", m.current) |
| 122 | return nil, nil |
| 123 | } |
| 124 | |
| 125 | func (m *mockKV) CAS(p *consul.KVPair, _ *consul.WriteOptions) (bool, *consul.WriteMeta, error) { |
| 126 | level.Debug(m.logger).Log("msg", "CAS", "key", p.Key, "modify_index", p.ModifyIndex, "value", fmt.Sprintf("%.40q", p.Value)) |