NewDB creates a new metadata database using the provided bolt database, content store, and snapshotters.
(db Transactor, cs content.Store, ss map[string]snapshots.Snapshotter, opts ...DBOpt)
| 118 | // NewDB creates a new metadata database using the provided |
| 119 | // bolt database, content store, and snapshotters. |
| 120 | func NewDB(db Transactor, cs content.Store, ss map[string]snapshots.Snapshotter, opts ...DBOpt) *DB { |
| 121 | m := &DB{ |
| 122 | db: db, |
| 123 | ss: make(map[string]*snapshotter, len(ss)), |
| 124 | dirtySS: map[string]struct{}{}, |
| 125 | dbopts: dbOptions{ |
| 126 | shared: true, |
| 127 | }, |
| 128 | } |
| 129 | |
| 130 | for _, opt := range opts { |
| 131 | opt(&m.dbopts) |
| 132 | } |
| 133 | |
| 134 | // Initialize data stores |
| 135 | m.cs = newContentStore(m, m.dbopts.shared, cs) |
| 136 | for name, sn := range ss { |
| 137 | m.ss[name] = newSnapshotter(m, name, sn) |
| 138 | } |
| 139 | |
| 140 | return m |
| 141 | } |
| 142 | |
| 143 | // Close closes the underlying bolt database. |
| 144 | // Acquires wlock so no GC cycle is in progress when bolt is closed. |
searching dependent graphs…