message

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OffsetOldest represents the smallest offset still available
	// Use it to consume all messages, starting at the first available
	OffsetOldest int64 = -2
	// OffsetNewest represents the offset that will be used for the next produce
	// Use it to consume only new messages
	OffsetNewest int64 = -1
	// OffsetInvalid is the offset returned when error is detected
	OffsetInvalid int64 = -3
)

Variables

View Source
var ErrCorrupted = errors.New("message corrupted")
View Source
var ErrInvalidOffset = errors.New("invalid offset")
View Source
var ErrNotFound = errors.New("not found")
View Source
var Invalid = Message{Offset: OffsetInvalid}

Functions

func Size

func Size(m Message) int64

func ValidateOffset

func ValidateOffset(offset int64) error

Types

type Message

type Message struct {
	Offset int64
	Time   time.Time
	Key    []byte
	Value  []byte
}

func Gen

func Gen(count int) []Message

type Reader

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

func OpenReader

func OpenReader(path string) (*Reader, error)

func OpenReaderMem

func OpenReaderMem(path string) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Consume

func (r *Reader) Consume(position, maxPosition int64, maxCount int64) ([]Message, error)

func (*Reader) Get

func (r *Reader) Get(position int64) (msg Message, err error)

func (*Reader) Read

func (r *Reader) Read(position int64) (msg Message, nextPosition int64, err error)

type Writer

type Writer struct {
	Path string
	// contains filtered or unexported fields
}

func OpenWriter

func OpenWriter(path string) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Size

func (w *Writer) Size() int64

func (*Writer) Sync

func (w *Writer) Sync() error

func (*Writer) SyncAndClose

func (w *Writer) SyncAndClose() error

func (*Writer) Write

func (w *Writer) Write(m Message) (int64, error)

Jump to

Keyboard shortcuts

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