--------------------------------------------------------
( options StoreOptions, persistOptions StorePersistOptions)
| 638 | // -------------------------------------------------------- |
| 639 | |
| 640 | func (s *Store) openCollection( |
| 641 | options StoreOptions, |
| 642 | persistOptions StorePersistOptions) (Collection, error) { |
| 643 | storeSnapshotInit, err := s.Snapshot() |
| 644 | if err != nil { |
| 645 | return nil, err |
| 646 | } |
| 647 | |
| 648 | co := options.CollectionOptions |
| 649 | co.LowerLevelInit = storeSnapshotInit |
| 650 | co.LowerLevelUpdate = func(higher Snapshot) (Snapshot, error) { |
| 651 | var ss Snapshot |
| 652 | var erro error |
| 653 | ss, erro = s.Persist(higher, persistOptions) |
| 654 | if erro != nil { |
| 655 | return nil, erro |
| 656 | } |
| 657 | |
| 658 | if storeSnapshotInit != nil { |
| 659 | storeSnapshotInit.Close() |
| 660 | storeSnapshotInit = nil |
| 661 | } |
| 662 | |
| 663 | return ss, erro |
| 664 | } |
| 665 | |
| 666 | storeFooter, ok := storeSnapshotInit.(*Footer) |
| 667 | if !ok { |
| 668 | storeSnapshotInit.Close() |
| 669 | return nil, fmt.Errorf("store: wrong storeSnapshotInit type") |
| 670 | } |
| 671 | |
| 672 | coll, err := restoreCollection(&co, storeFooter) |
| 673 | if err != nil { |
| 674 | storeSnapshotInit.Close() |
| 675 | return nil, err |
| 676 | } |
| 677 | |
| 678 | err = coll.Start() |
| 679 | if err != nil { |
| 680 | storeSnapshotInit.Close() |
| 681 | return nil, err |
| 682 | } |
| 683 | |
| 684 | return coll, nil |
| 685 | } |
| 686 | |
| 687 | // statsReporter interface represents stats reporting methods. |
| 688 | type statsReporter interface { |
no test coverage detected