Documentation ¶
Index ¶
- type Database
- func (d *Database) CountEventsWithAppServiceID(ctx context.Context, appServiceID string) (int, error)
- func (d *Database) GetEventsWithAppServiceID(ctx context.Context, appServiceID string, limit int) (int, int, []gomatrixserverlib.HeaderedEvent, bool, error)
- func (d *Database) GetLatestTxnID(ctx context.Context) (int, error)
- func (d *Database) RemoveEventsBeforeAndIncludingID(ctx context.Context, appserviceID string, eventTableID int) error
- func (d *Database) StoreEvent(ctx context.Context, appServiceID string, ...) error
- func (d *Database) UpdateTxnIDForEvents(ctx context.Context, appserviceID string, maxID, txnID int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { sqlutil.PartitionOffsetStatements // contains filtered or unexported fields }
Database stores events intended to be later sent to application services
func NewDatabase ¶
func NewDatabase(dbProperties *config.DatabaseOptions) (*Database, error)
NewDatabase opens a new database
func (*Database) CountEventsWithAppServiceID ¶
func (d *Database) CountEventsWithAppServiceID( ctx context.Context, appServiceID string, ) (int, error)
CountEventsWithAppServiceID returns the number of events destined for an application service given its ID.
func (*Database) GetEventsWithAppServiceID ¶
func (d *Database) GetEventsWithAppServiceID( ctx context.Context, appServiceID string, limit int, ) (int, int, []gomatrixserverlib.HeaderedEvent, bool, error)
GetEventsWithAppServiceID returns a slice of events and their IDs intended to be sent to an application service given its ID.
func (*Database) GetLatestTxnID ¶
GetLatestTxnID returns the latest available transaction id
func (*Database) RemoveEventsBeforeAndIncludingID ¶
func (d *Database) RemoveEventsBeforeAndIncludingID( ctx context.Context, appserviceID string, eventTableID int, ) error
RemoveEventsBeforeAndIncludingID removes all events from the database that are less than or equal to a given maximum ID. IDs here are implemented as a serial, thus this should always delete events in chronological order.
func (*Database) StoreEvent ¶
func (d *Database) StoreEvent( ctx context.Context, appServiceID string, event *gomatrixserverlib.HeaderedEvent, ) error
StoreEvent takes in a gomatrixserverlib.HeaderedEvent and stores it in the database for a transaction worker to pull and later send to an application service.
func (*Database) UpdateTxnIDForEvents ¶
func (d *Database) UpdateTxnIDForEvents( ctx context.Context, appserviceID string, maxID, txnID int, ) error
UpdateTxnIDForEvents takes in an application service ID and a and stores them in the DB, unless the pair already exists, in which case it updates them.