sqlitehistory

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package sqlitehistory implements watermillchat.HistoryRepository using a modern SQLite backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

func New added in v0.0.4

func New(p RepositoryParameters) (r *Repository, err error)

func NewUsingFile added in v0.0.4

func NewUsingFile(f string, p RepositoryParameters) (*Repository, error)

func (*Repository) GetRoomMessages

func (r *Repository) GetRoomMessages(ctx context.Context, roomName string) (messages []watermillchat.Message, err error)

func (*Repository) Insert

func (r *Repository) Insert(ctx context.Context, m watermillchat.Broadcast) (err error)

func (*Repository) Listen

func (r *Repository) Listen(broadcasts <-chan *message.Message)

type RepositoryParameters

type RepositoryParameters struct {
	Context    context.Context
	Connection *sqlite.Conn

	// Retention constraints the life time of messages before deletion. Defaults to [watermillchat.DefaultHistoryRetention].
	Retention time.Duration

	// CleanUpFrequency is the pause between message purge
	// cycles based on retention. Defaults to [watermillchat.DefaultHistoryCleanupFrequency].
	CleanUpFrequency time.Duration

	// MostMessagesPerRoom constraints the maximum number of
	// returned messages per room when history is loaded using
	// [Repository.GetRoomMessages]. More messages may still
	// be present in the database, if they retention duration
	// has not yet run out. Defaults to [watermillchat.DefaultHistoryDepth].
	MostMessagesPerRoom int64

	// Logger reports any problems associated with delivery.
	// Defaults to [slog.Default].
	Logger *slog.Logger
}

Jump to

Keyboard shortcuts

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