sqlite

package
v1.5.1-0...-475df33 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sqlite implements sqlite-backed message storage and migrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DayCount

type DayCount = store.DayCount

DayCount remains an alias for callers that historically imported the SQLite package directly.

type DeletionRequest

type DeletionRequest = store.DeletionRequest

DeletionRequest remains an alias for callers that historically imported the SQLite package directly.

type Storage

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

Storage mirrors sqlite.ts's SqliteMessageStorage. All exported methods hold mu for their whole duration - unlike Node's single-threaded event loop, which gives run_migrations/downgrade_to's multi-statement "transactions" atomicity for free just by never interleaving other calls in between, Go callers (one goroutine per network connection, see internal/ircbridge) can call Index/GetMessages/etc concurrently. mu serializes them the same way Node's event loop implicitly did, and (with db capped to a single connection) makes the plain, unwrapped "BEGIN EXCLUSIVE TRANSACTION"/"COMMIT"/"ROLLBACK" statements below safe to issue as ordinary Exec calls rather than needing a pinned *sql.Conn.

func New

func New(username, logsPath string) *Storage

New mirrors `new SqliteMessageStorage(userName)`. logsPath is the user logs directory (Config.getUserLogsPath()); Enable joins it with "<username>.sqlite3", matching sqlite.ts's enable().

func (*Storage) CanProvideMessages

func (s *Storage) CanProvideMessages() bool

CanProvideMessages mirrors sqlite.ts's canProvideMessages().

func (*Storage) Close

func (s *Storage) Close()

Close mirrors sqlite.ts's close().

func (*Storage) CountMessagesOfType

func (s *Storage) CountMessagesOfType(msgType model.MessageType) int

CountMessagesOfType mirrors sqlite.ts's countMessagesOfType().

func (*Storage) CountMessagesOfTypePerDay

func (s *Storage) CountMessagesOfTypePerDay(msgType model.MessageType, sinceMs int64) []DayCount

CountMessagesOfTypePerDay mirrors sqlite.ts's countMessagesOfTypePerDay().

func (*Storage) DatabaseSize

func (s *Storage) DatabaseSize() int64

DatabaseSize returns the on-disk size of this user's SQLite database and its WAL/SHM sidecars. It is intentionally independent of message-log text files, which are reported separately as Relay storage.

func (*Storage) DeleteChannel

func (s *Storage) DeleteChannel(network *model.Network, channel *model.Chan)

DeleteChannel mirrors sqlite.ts's deleteChannel().

func (*Storage) DeleteMessages

func (s *Storage) DeleteMessages(req DeletionRequest) (int64, error)

DeleteMessages mirrors sqlite.ts's deleteMessages().

func (*Storage) Downgrade

func (s *Storage) Downgrade() (int64, error)

Downgrade mirrors sqlite.ts's downgrade().

func (*Storage) DowngradeTo

func (s *Storage) DowngradeTo(version int64) (int64, error)

DowngradeTo mirrors sqlite.ts's downgrade_to.

func (*Storage) Enable

func (s *Storage) Enable() error

Enable mirrors sqlite.ts's enable().

func (*Storage) ExportMessages

func (s *Storage) ExportMessages() ([]store.MessageRecord, error)

ExportMessages returns all rows for the explicit PostgreSQL import tool. The source database remains untouched.

func (*Storage) GetMessages

func (s *Storage) GetMessages(network *model.Network, channel *model.Chan, nextID func() int, limit int, before *store.MessageCursor) store.MessagePage

GetMessages mirrors sqlite.ts's getMessages().

func (*Storage) Index

func (s *Storage) Index(network *model.Network, channel *model.Chan, msg *model.Msg)

Index mirrors sqlite.ts's index().

func (*Storage) IsEnabled

func (s *Storage) IsEnabled() bool

IsEnabled mirrors the `isEnabled` field read from outside the class.

func (*Storage) Search

func (s *Storage) Search(query store.SearchQuery) (store.SearchResponse, error)

Search mirrors sqlite.ts's search() and uses the FTS5 index for normal word-like queries, retaining literal LIKE matching for punctuation-heavy queries that FTS5 cannot represent as a plain text search.

func (*Storage) Update

func (s *Storage) Update(network *model.Network, channel *model.Chan, msg *model.Msg)

Update persists mutable fields on an already-indexed message, currently reactions. Message IDs are client-local and are reassigned when history is loaded, so the stable IRC msgid identifies the row instead.

func (*Storage) Vacuum

func (s *Storage) Vacuum() error

Vacuum mirrors the vacuum() helper method, meant to be used by migration-related CLI commands.

Jump to

Keyboard shortcuts

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