Documentation ¶
Overview ¶
Package storage implements the database layer of the client.
Index ¶
- type AfterIDIter
- type AfterIDResult
- type DB
- func (db *DB) AfterID(ctx context.Context) AfterIDIter
- func (db *DB) BeforeID(ctx context.Context, j jid.JID) (string, time.Time, error)
- func (db *DB) ForRoster(ctx context.Context, f func(event.UpdateRoster)) error
- func (db *DB) GetInfo(ctx context.Context, j jid.JID) (disco.Info, disco.Caps, error)
- func (db *DB) GetServices(ctx context.Context, feature info.Feature) ([]jid.JID, error)
- func (db *DB) InsertCaps(ctx context.Context, j jid.JID, caps disco.Caps) error
- func (db *DB) InsertMsg(ctx context.Context, respectDelay bool, msg event.ChatMessage, addr jid.JID) error
- func (db *DB) MarkReceived(ctx context.Context, e event.Receipt) error
- func (db *DB) QueryHistory(ctx context.Context, j string, typ stanza.MessageType) MessageIter
- func (db *DB) ReplaceRoster(ctx context.Context, e event.FetchRoster) error
- func (db *DB) RosterVer(ctx context.Context) (string, error)
- func (db *DB) UpdateRoster(ctx context.Context, ver string, item event.UpdateRoster) error
- func (db *DB) UpsertDisco(ctx context.Context, j jid.JID, caps disco.Caps, info disco.Info) error
- type Iter
- type MessageIter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterIDIter ¶
type AfterIDIter struct {
*Iter
}
AfterIDIter is an iterator that can return concrete AfterIDRes values.
func (AfterIDIter) Result ¶
func (iter AfterIDIter) Result() AfterIDResult
Result returns the most recent result read from the iter.
type AfterIDResult ¶
AfterIDRes is returned from an AfterID query.
type DB ¶
DB represents a SQL database with common pre-prepared statements.
func OpenDB ¶
func OpenDB(ctx context.Context, appName, account, dbFile, schema string, p *message.Printer, debug *log.Logger) (*DB, error)
OpenDB attempts to open the database at dbFile. If no database can be found one is created. If dbFile is empty a fallback sequence of names is used starting with $XDG_DATA_HOME, then falling back to $HOME/.local/share, then falling back to the current working directory.
func (*DB) AfterID ¶
func (db *DB) AfterID(ctx context.Context) AfterIDIter
AfterID gets the last known message ID assigned by the 'by' JID for each roster entry.
func (*DB) GetInfo ¶
GetInfo queries for service discovery information and entity caps.
The stored caps value does not necessarily match the caps value as calculated from the returned disco info. The info is populated whenever we fetch it, the caps value is populated whenever we see a new value advertised for a JID. By comparing the two we can see if a newer version has been advertised and then go fetch the latest version, but only when we need it (not when the new version is advertised).
func (*DB) GetServices ¶
GetServices returns the JIDs of the services which advertised the given feature.
func (*DB) InsertCaps ¶
InsertCaps adds a newly seen entity capbailities hash to the databsae.
func (*DB) InsertMsg ¶
func (db *DB) InsertMsg(ctx context.Context, respectDelay bool, msg event.ChatMessage, addr jid.JID) error
InsertMsg adds a message to the database.
func (*DB) MarkReceived ¶
MarkReceived marks a message as having been received by the other side.
func (*DB) QueryHistory ¶
func (db *DB) QueryHistory(ctx context.Context, j string, typ stanza.MessageType) MessageIter
QueryHistory returns all rows to or from the given JID. Any errors encountered while querying are deferred until the iter is used.
func (*DB) ReplaceRoster ¶
ReplaceRoster truncates the entire roster and replaces it with the provided items.
func (*DB) UpdateRoster ¶
UpdateRoster upserts or removes a JID from the roster.
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter is a generic iterator that can be returned to marshal database rows into values.
func (*Iter) Close ¶
Close stops iteration. If Next is called and returns false, Close is called automatically. Close is idempotent and does not affect the result of Err.
type MessageIter ¶
type MessageIter struct {
*Iter
}
MessageIter is an iterator that can return concrete messages.
func (MessageIter) Message ¶
func (iter MessageIter) Message() event.ChatMessage
Result returns the most recent result read from the iter.