offset

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogManager

type LogManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LogManager provides writers the ability to track offsets associated with processed messages.

func NewLogManager

func NewLogManager(path, name string) (*LogManager, error)

NewLogManager creates a new instance of LogManager and initializes its namespace map by reading any existing log files.

func (*LogManager) CommitOffset

func (m *LogManager) CommitOffset(o Offset, override bool) error

CommitOffset verifies it does not contain an offset older than the current offset and persists to the log.

func (*LogManager) NewestOffset

func (m *LogManager) NewestOffset() int64

NewestOffset loops over every offset and returns the highest one.

func (*LogManager) OffsetMap

func (m *LogManager) OffsetMap() map[string]uint64

OffsetMap provides access to the underlying map containing the newest offset for every namespace.

type Manager

type Manager interface {
	CommitOffset(Offset, bool) error
	OffsetMap() map[string]uint64
	NewestOffset() int64
}

Manager defines the necessary functions for providing the ability to manage offsets associated with a commitlog.CommitLog.

type MockManager

type MockManager struct {
	MemoryMap   map[string]uint64
	CommitDelay time.Duration
	CommitErr   error
	sync.Mutex
}

MockManager implements offset.Manager for use in tests.

func (*MockManager) CommitOffset

func (m *MockManager) CommitOffset(o Offset, override bool) error

CommitOffset satisfies offset.Manager interface.

func (*MockManager) NewestOffset

func (m *MockManager) NewestOffset() int64

NewestOffset satisfies offset.Manager interface.

func (*MockManager) OffsetMap

func (m *MockManager) OffsetMap() map[string]uint64

OffsetMap satisfies offset.Manager interface.

type Offset

type Offset struct {
	Namespace string
	LogOffset uint64
	Timestamp int64
}

Offset defines the structure a writer needs to supply for tracking.

func (Offset) Bytes

func (o Offset) Bytes() []byte

Bytes converts Offset to the binary format to be stored on disk.

Jump to

Keyboard shortcuts

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