checkpoint

package
v0.0.0-...-fe70ff5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AaLogState

type AaLogState struct {
	FileName     string `yaml:"file_name"`     // Name of the file being read. Don't need full path as the configuration has the folder.
	RecordNumber uint64 `yaml:"record_number"` // Number of the record last read
	RecordOffset int32  `yaml:"record_offset"` // Byte position of the start of the last record read in the file.
}

AaLogState represents the state of an individual log file.

type Checkpoint

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

Checkpoint persists log state information to disk.

func NewCheckpoint

func NewCheckpoint(file string, maxUpdates int, interval time.Duration) (*Checkpoint, error)

NewCheckpoint creates and returns a new Checkpoint. This method loads state information from disk if it exists and starts a goroutine for persisting state information to disk. Shutdown should be called when finished to guarantee any in-memory state information is flushed to disk.

file is the name of the file where event log state is persisted as YAML. maxUpdates is the maximum number of updates checkpoint will accept before triggering a flush to disk. interval is maximum amount of time that can pass since the last flush before triggering a flush to disk (minimum value is 1s).

func (*Checkpoint) Persist

func (c *Checkpoint) Persist(fileName string, recordNumber uint64, recordOffset int32)

Persist queues the given log state information to be written to disk.

func (*Checkpoint) PersistState

func (c *Checkpoint) PersistState(st AaLogState)

PersistState queues the given log state to be written to disk.

func (*Checkpoint) Shutdown

func (c *Checkpoint) Shutdown()

Shutdown stops the checkpoint worker (which persists any state to disk as it stops). This method blocks until the checkpoint worker shutdowns. Calling this method more once is safe and has no effect.

func (*Checkpoint) State

func (c *Checkpoint) State() AaLogState

State returns the current in-memory log state. This state information is bootstrapped with any data found on disk at creation time.

type PersistedState

type PersistedState struct {
	UpdateTime time.Time  `yaml:"update_time"`
	State      AaLogState `yaml:"logs"`
}

PersistedState represents the format of the data persisted to disk.

Jump to

Keyboard shortcuts

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