checkpoint

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package checkpoint persists event log state information to disk so that event log monitoring can resume from the last read event in the case of a restart or unexpected interruption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

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

Checkpoint persists event 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(name string, recordNumber uint64, ts time.Time)

Persist queues the given event log state information 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) States

func (c *Checkpoint) States() map[string]EventLogState

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

type EventLogState

type EventLogState struct {
	Name         string    `yaml:"name"`
	RecordNumber uint64    `yaml:"record_number"`
	Timestamp    time.Time `yaml:"timestamp"`
}

EventLogState represents the state of an individual event log.

type PersistedState

type PersistedState struct {
	UpdateTime time.Time       `yaml:"update_time"`
	States     []EventLogState `yaml:"event_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