Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresLoader ¶
type PostgresLoader struct {
// contains filtered or unexported fields
}
func LoadAll ¶
This function queries the database to get all the data, and is guaranteed to return an EventProducer with a single "events.Save" object already in the channel before returning.
The string query should return Rows with the following columns and types:
- id: string
- data: JSON
- type: string ("request" or "imp")
func (*PostgresLoader) Invalidations ¶
func (e *PostgresLoader) Invalidations() <-chan events.Invalidation
func (*PostgresLoader) Saves ¶
func (e *PostgresLoader) Saves() <-chan events.Save
type PostgresPoller ¶
type PostgresPoller struct {
// contains filtered or unexported fields
}
func PollForUpdates ¶
func PollForUpdates(ctxProducer func() (ctx context.Context, canceller func()), db *sql.DB, query string, startUpdatesFrom time.Time, refreshRate time.Duration) (eventProducer *PostgresPoller)
PollForUpdates returns an EventProducer which checks the database for updates every refreshRate.
This object will prioritize thoroughness over efficiency. In rare cases it may produce two "update" events for the same DB save, but it should never "miss" a database update either.
The Queries should return a ResultSet with the following columns and types:
- id: string
- data: JSON
- type: string ("request" or "imp")
If data is empty or the JSON "null", then the ID will be invalidated (e.g. a deletion). If data is not empty, it should be the Stored Request or Stored Imp data associated with the given ID.
func (*PostgresPoller) Invalidations ¶
func (e *PostgresPoller) Invalidations() <-chan events.Invalidation
func (*PostgresPoller) Saves ¶
func (e *PostgresPoller) Saves() <-chan events.Save