ForEach runs method for each snapshot
(handler func(*Snapshot) error)
| 353 | |
| 354 | // ForEach runs method for each snapshot |
| 355 | func (collection *SnapshotCollection) ForEach(handler func(*Snapshot) error) error { |
| 356 | return collection.db.ProcessByPrefix([]byte("S"), func(_, blob []byte) error { |
| 357 | s := &Snapshot{} |
| 358 | if err := s.Decode(blob); err != nil { |
| 359 | log.Printf("Error decoding snapshot: %s\n", err) |
| 360 | return nil |
| 361 | } |
| 362 | |
| 363 | return handler(s) |
| 364 | }) |
| 365 | } |
| 366 | |
| 367 | // ForEachSorted runs method for each snapshot following some sort order |
| 368 | func (collection *SnapshotCollection) ForEachSorted(sortMethod string, handler func(*Snapshot) error) error { |