Documentation ¶
Index ¶
- Constants
- Variables
- type MemoryStorage
- func (m *MemoryStorage) ChannelExists(channel string) bool
- func (m *MemoryStorage) CreateChannel(channel string) error
- func (m *MemoryStorage) GetMessages(channel string, subscriberID string, offset uint64) ([]*pb.Message, uint64, error)
- func (m *MemoryStorage) RemoveChannelFromSubscriberMap(channel string, subscriberID string)
- func (m *MemoryStorage) SaveMessage(channel string, message *pb.Message) (uint64, error)
- type MemoryStorageOptions
- type Storage
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 ¶
SaveMessage saves a message to the specified channel
type MemoryStorageOptions ¶
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
Click to show internal directories.
Click to hide internal directories.