messagestore

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 6 Imported by: 3

README

message-store

a library which implements a traditional messaging store.

text files are used for persistence.

a topic is persistence, which can contain entries.

an entry has a key and a value.

entries are written to a topic by appending to the topic text file.

entries are read from a topic by providing an offset.

entries in a topic cannot be queried.

entries in a topic are immutable, meaning they cannot be modified after they are written.

usage

go get -v github.com/mmcnicol/message-store@v0.0.3

public API

NewMessageStore() *MessageStore

SaveEntry(topic string, entry Entry) (int64, error)

ReadEntry(topic string, offset int64) (*Entry, error)

PollForNextEntry(topic string, offset int64, pollDuration time.Duration) (*Entry, error)

Delete(topic string)

associated projects

message store server

message store sdk

inspired by

kafka

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key       []byte
	Value     []byte
	Timestamp time.Time
}

Entry represents a generic entry

type Index

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

Index represents the index file

type IndexEntry

type IndexEntry struct {
	Offset int64
	Pos    int64
	Length int64
}

IndexEntry represents an entry in the index

type MessageStore

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

MessageStore manages topics and stores topic entries in text files

func NewMessageStore

func NewMessageStore() *MessageStore

NewMessageStore creates a new instance of MessageStore

func (*MessageStore) Delete

func (ms *MessageStore) Delete(topic string) error

Delete will remove the specified topic

func (*MessageStore) PollForNextEntry added in v0.0.3

func (ms *MessageStore) PollForNextEntry(topic string, offset int64, pollDuration time.Duration) (*Entry, error)

PollForNextEntry reads an entry from the given offset+1 from the specified topic, after sleeping for the specified poll interval

func (*MessageStore) ReadEntry

func (ms *MessageStore) ReadEntry(topic string, offset int64) (*Entry, error)

ReadEntry reads an entry from the given offset from the specified topic

func (*MessageStore) SaveEntry

func (ms *MessageStore) SaveEntry(topic string, entry Entry) (int64, error)

SaveEntry saves an entry to the specified topic

Jump to

Keyboard shortcuts

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