commit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

commit package provides commit logs for storing mutations, as they arrive at the server. Mutations also get stored in memory within posting.List. So, commit logs are useful to handle machine crashes, and re-init of a posting list. This package provides functionality to write to a rotating log, and a way to quickly filter relevant entries corresponding to an attribute.

Index

Constants

This section is empty.

Variables

View Source
var E_READ = errors.New("Unable to read")
View Source
var E_WRITE = errors.New("Unable to write")

Functions

func FillCache

func FillCache(c *Cache, path string) error

Types

type ByTimestamp

type ByTimestamp []*logFile

func (ByTimestamp) Len

func (b ByTimestamp) Len() int

func (ByTimestamp) Less

func (b ByTimestamp) Less(i, j int) bool

func (ByTimestamp) Swap

func (b ByTimestamp) Swap(i, j int)

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Cache) LastAccessedInSeconds

func (c *Cache) LastAccessedInSeconds() int64

func (*Cache) Present

func (c *Cache) Present(hash uint32) bool

func (*Cache) ReadAt

func (c *Cache) ReadAt(pos int, p []byte) (n int, err error)

func (*Cache) Write

func (c *Cache) Write(hash uint32, p []byte) (n int, err error)

type CurFile

type CurFile struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CurFile) Size

func (c *CurFile) Size() int64
type Header struct {
	// contains filtered or unexported fields
}

type LogIterator

type LogIterator func(hdr Header, record []byte)

type Logger

type Logger struct {

	// Sync every N logs. A value of zero or less would mean
	// sync every append to file.
	SyncEvery int

	// Sync every d duration.
	SyncDur time.Duration

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(dir string, fileprefix string, maxSize int64) *Logger

func (*Logger) AddLog

func (l *Logger) AddLog(hash uint32, value []byte) (int64, error)

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) DeleteCacheOlderThan

func (l *Logger) DeleteCacheOlderThan(v time.Duration)

func (*Logger) Init

func (l *Logger) Init()

func (*Logger) StreamEntries

func (l *Logger) StreamEntries(afterTs int64, hash uint32,
	iter LogIterator) error

type Reader

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

Reader isn't thread-safe. But multiple readers can be used to read the same cache.

func NewReader

func NewReader(c *Cache) *Reader

func (*Reader) Discard

func (r *Reader) Discard(n int)

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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