truncator

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTruncatorAlreadyRunning = errors.New("truncator already running")
	ErrTruncatorAlreadyStopped = errors.New("truncator already stopped")
)

Functions

This section is empty.

Types

type Truncator

type Truncator struct {
	// contains filtered or unexported fields
}

func NewTruncator

func NewTruncator(
	db database.DB,
	retentionPeriod time.Duration,
	truncationFrequency time.Duration,
	logger logger.Logger) *Truncator

func (*Truncator) Start

func (t *Truncator) Start() error

runTruncator triggers periodically to truncate multiple appendable logs

func (*Truncator) Stop

func (t *Truncator) Stop() error

func (*Truncator) Truncate

func (t *Truncator) Truncate(ctx context.Context, retentionPeriod time.Duration) error

Truncate discards all data from the database that is older than the retention period. Truncation discards an appendable log upto a given offset before time ts. First, the transaction is fetched which lies before the specified time period, and then the values are discarded upto the specified offset.

  discard point
		|
		|
		v

--------+-------+--------+----------

	|       |        |
tn-1:vx  tn:vx   tn+1:vx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL