AddCounter returns a fresh copy of n, with Counter c added in. (counters are stored as strings, to keep the data structure simple)
(k string, value int)
| 93 | // AddCounter returns a fresh copy of n, with Counter c added in. |
| 94 | // (counters are stored as strings, to keep the data structure simple) |
| 95 | func (n Node) AddCounter(k string, value int) Node { |
| 96 | name := CounterPrefix + k |
| 97 | if prevValue, found := n.LookupCounter(k); found { |
| 98 | value += prevValue |
| 99 | } |
| 100 | return n.WithLatest(name, mtime.Now(), strconv.Itoa(value)) |
| 101 | } |
| 102 | |
| 103 | // WithSet returns a fresh copy of n, with set merged in at key. |
| 104 | func (n Node) WithSet(key string, set StringSet) Node { |