Documentation
¶
Overview ¶
Package sqlite implements sqlite-backed message storage and migrations.
Index ¶
- type DayCount
- type DeletionRequest
- type Storage
- func (s *Storage) CanProvideMessages() bool
- func (s *Storage) Close()
- func (s *Storage) CountMessagesOfType(msgType model.MessageType) int
- func (s *Storage) CountMessagesOfTypePerDay(msgType model.MessageType, sinceMs int64) []DayCount
- func (s *Storage) DatabaseSize() int64
- func (s *Storage) DeleteChannel(network *model.Network, channel *model.Chan)
- func (s *Storage) DeleteMessages(req DeletionRequest) (int64, error)
- func (s *Storage) Downgrade() (int64, error)
- func (s *Storage) DowngradeTo(version int64) (int64, error)
- func (s *Storage) Enable() error
- func (s *Storage) ExportMessages() ([]store.MessageRecord, error)
- func (s *Storage) GetMessages(network *model.Network, channel *model.Chan, nextID func() int, limit int, ...) store.MessagePage
- func (s *Storage) Index(network *model.Network, channel *model.Chan, msg *model.Msg)
- func (s *Storage) IsEnabled() bool
- func (s *Storage) Search(query store.SearchQuery) (store.SearchResponse, error)
- func (s *Storage) Update(network *model.Network, channel *model.Chan, msg *model.Msg)
- func (s *Storage) Vacuum() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type 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 ¶
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 ¶
CanProvideMessages mirrors sqlite.ts's canProvideMessages().
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 ¶
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 ¶
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) DowngradeTo ¶
DowngradeTo mirrors sqlite.ts's downgrade_to.
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) 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.