storage

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OffsetBeginning is the offset to start reading messages from the beginning
	OffsetBeginning uint64 = 0

	// OffsetLatest is the offset to start reading messages from the latest
	OffsetLatest uint64 = ^uint64(0)
)

Variables

View Source
var (
	// ErrInvalidOffset is returned when an invalid offset is provided
	ErrInvalidOffset = errors.New("error: invalid offset provided for message retrieval")

	// ErrInternal is returned when storage is unavailable
	ErrInternal = errors.New("error: storage unavailable")
)

Functions

This section is empty.

Types

type MemoryStorage

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

MemoryStorage is an in-memory implementation of the Storage interface

func NewMemoryStorage

func NewMemoryStorage(logger *zap.Logger, options *MemoryStorageOptions) *MemoryStorage

NewMemoryStorage initializes a new MemoryStorage instance

func (*MemoryStorage) ChannelExists

func (m *MemoryStorage) ChannelExists(channel string) bool

ChannelExists checks if a channel exists

func (*MemoryStorage) CreateChannel

func (m *MemoryStorage) CreateChannel(channel string) error

CreateChannel creates a new channel

func (*MemoryStorage) GetMessages

func (m *MemoryStorage) GetMessages(
	channel string,
	subscriberID string,
	offset uint64,
) ([]*pb.Message, uint64, error)

GetMessages retrieves all messages from the specified channel

func (*MemoryStorage) RemoveChannelFromSubscriberMap

func (m *MemoryStorage) RemoveChannelFromSubscriberMap(
	channel string,
	subscriberID string,
)

RemoveChannelFromSubscriberMap removes the channel from the subscriberToChannelChunk map

func (*MemoryStorage) SaveMessage

func (m *MemoryStorage) SaveMessage(
	channel string,
	message *pb.Message,
) (uint64, error)

SaveMessage saves a message to the specified channel

type MemoryStorageOptions

type MemoryStorageOptions struct {
	Wal           *wal.WAL
	BatchSize     uint64
	SyncOnStartup bool
}

MemoryStorageOptions represents the options for the MemoryStorage

type Storage

type Storage interface {
	SaveMessage(string, *pb.Message) (uint64, error)
	GetMessages(string, string, uint64) ([]*pb.Message, uint64, error)
	CreateChannel(string) error
	ChannelExists(string) bool
	RemoveChannelFromSubscriberMap(string, string)
}

Storage defines the interface for message storage mechanisms

Jump to

Keyboard shortcuts

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