| 136 | } |
| 137 | |
| 138 | func NewStore(dbs []*DB, levels CompactionLevels) *Store { |
| 139 | s := &Store{ |
| 140 | dbs: dbs, |
| 141 | levels: levels, |
| 142 | |
| 143 | SnapshotInterval: DefaultSnapshotInterval, |
| 144 | SnapshotRetention: DefaultSnapshotRetention, |
| 145 | L0Retention: DefaultL0Retention, |
| 146 | L0RetentionCheckInterval: DefaultL0RetentionCheckInterval, |
| 147 | CompactionMonitorEnabled: true, |
| 148 | RetentionEnabled: true, |
| 149 | ShutdownSyncTimeout: DefaultShutdownSyncTimeout, |
| 150 | ShutdownSyncInterval: DefaultShutdownSyncInterval, |
| 151 | HeartbeatCheckInterval: DefaultHeartbeatCheckInterval, |
| 152 | Logger: slog.Default().With(LogKeySystem, LogSystemStore), |
| 153 | } |
| 154 | |
| 155 | for _, db := range dbs { |
| 156 | db.SetLogger(s.Logger.With(LogKeyDB, filepath.Base(db.Path()))) |
| 157 | db.L0Retention = s.L0Retention |
| 158 | db.ShutdownSyncTimeout = s.ShutdownSyncTimeout |
| 159 | db.ShutdownSyncInterval = s.ShutdownSyncInterval |
| 160 | db.VerifyCompaction = s.VerifyCompaction |
| 161 | db.RetentionEnabled = s.RetentionEnabled |
| 162 | } |
| 163 | s.ctx, s.cancel = context.WithCancel(context.Background()) |
| 164 | return s |
| 165 | } |
| 166 | |
| 167 | func (s *Store) Open(ctx context.Context) error { |
| 168 | if err := s.levels.Validate(); err != nil { |