postgres

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database stores events intended to be later sent to application services

func NewDatabase

func NewDatabase(base *base.BaseDendrite, 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

func (d *Database) GetLatestTxnID(
	ctx context.Context,
) (int, error)

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.

Jump to

Keyboard shortcuts

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