postgres

package
v0.0.0-...-f16c7e7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

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

func LoadAll(ctx context.Context, db *sql.DB, query string) (eventProducer *PostgresLoader)

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:

  1. id: string
  2. data: JSON
  3. 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:

  1. id: string
  2. data: JSON
  3. 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

Jump to

Keyboard shortcuts

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