const ( ModePeriodic = "periodic" ModeRevision = "revision" )
type Compactable interface { Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) }
Compactor purges old log from the storage periodically.
type Compactor interface { // Run starts the main loop of the compactor in background. // Use Stop() to halt the loop and release the resource. Run() // Stop halts the main loop of the compactor. Stop() // Pause temporally suspend the compactor not to run compaction. Resume() to unpose. Pause() // Resume restarts the compactor suspended by Pause(). Resume() }
func New( lg *zap.Logger, mode string, retention time.Duration, rg RevGetter, c Compactable, ) (Compactor, error)
New returns a new Compactor based on given "mode".
Periodic compacts the log by purging revisions older than the configured retention time.
type Periodic struct {
// contains filtered or unexported fields
}
func (pc *Periodic) Pause()
Pause pauses periodic compactor.
func (pc *Periodic) Resume()
Resume resumes periodic compactor.
func (pc *Periodic) Run()
Run runs periodic compactor.
func (pc *Periodic) Stop()
Stop stops periodic compactor.
type RevGetter interface { Rev() int64 }
Revision compacts the log by purging revisions older than the configured reivison number. Compaction happens every 5 minutes.
type Revision struct {
// contains filtered or unexported fields
}
func (rc *Revision) Pause()
Pause pauses revision-based compactor.
func (rc *Revision) Resume()
Resume resumes revision-based compactor.
func (rc *Revision) Run()
Run runs revision-based compactor.
func (rc *Revision) Stop()
Stop stops revision-based compactor.