ForeachInRange runs fn for each key/value pair in kv in the range of start and end, which behave the same as kv.Find. If fn returns an error, that same error is returned from Foreach and iteration stops.
(kv KeyValue, start, end string, fn func(key, value string) error)
| 282 | // an error, that same error is returned from Foreach and iteration |
| 283 | // stops. |
| 284 | func ForeachInRange(kv KeyValue, start, end string, fn func(key, value string) error) error { |
| 285 | it := kv.Find(start, end) |
| 286 | for it.Next() { |
| 287 | if err := fn(it.Key(), it.Value()); err != nil { |
| 288 | it.Close() |
| 289 | return err |
| 290 | } |
| 291 | } |
| 292 | return it.Close() |
| 293 | } |
| 294 | |
| 295 | // CheckSizes returns ErrKeyTooLarge if key does not respect KeyMaxSize or |
| 296 | // ErrValueTooLarge if value does not respect ValueMaxSize |