Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEventID ¶
func ValidateSchema ¶
Migrate migrates the Postgres schema to the current version.
Types ¶
type DBConfig ¶
type DBConfig struct { DBConnMaxLifetime string `usage:"max lifetime for a db connection, duration format e.g. '10s', '1m'" value:"300s"` DBMaxIdleConns int `usage:"max idle database connections" value:"10"` DBMaxOpenConns int `usage:"max open database connections" value:"10"` PGDatabase string `name:"pgdb" env:"PGDATABASE"` PGHost string `name:"pghost" env:"PGHOST"` PGPassword string `name:"pgpassword" env:"PGPASSWORD"` PGPort int `name:"pgport" env:"PGPORT" value:"5432"` PGSSLMode string `name:"pgsslmode" env:"PGSSLMODE"` PGUser string `name:"pguser" env:"PGUSER"` }
DBConfig contains database-releated config settings Note: naming in this config shares namespace with the global config, hence the "DB" and "PG" prefixes for its keys.
type Event ¶
type EventCreator ¶
type EventCreator interface { // CreateEvents creates the provided events. CreateEvents(context.Context, []Event) error }
EventCreator creates events.
type EventLister ¶
type EventLister interface { // ListUniqueEvents lists events. If ids is non-empty, it is used to filter the // result. ListUniqueEvents(ctx context.Context, ids []uuid.UUID) ([]Event, error) }
EventLister lists events using an optional filter.
type EventListerCreator ¶
type EventListerCreator interface { EventCreator EventLister }
EventListerCreator supprots both creating and listing events. This is required by the target of the Update functionality.
type EventStorage ¶
type EventStorage struct {
// contains filtered or unexported fields
}
func NewEventStorage ¶
func NewEventStorage(db *sql.DB) *EventStorage
func (*EventStorage) CreateEvents ¶
func (s *EventStorage) CreateEvents( ctx context.Context, events []Event, ) (retErr error)
func (*EventStorage) ListUniqueEvents ¶
type RSS ¶
type RSS struct { XMLName xml.Name `xml:"rss"` Channel RSSChannel }
type RSSAdapter ¶
type RSSAdapter struct {
// contains filtered or unexported fields
}
RSSAdapter makes it possible to use the RSS Events functions as an EventLister.
func NewRSSAdapter ¶
func (*RSSAdapter) ListUniqueEvents ¶
ListUniqueEvents lists events found in the RSS feeds for the given regions
type RSSChannel ¶
type RSSFeedItem ¶
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
func NewUpdater ¶
func NewUpdater() *Updater
func (*Updater) Update ¶
func (u *Updater) Update( ctx context.Context, rss EventLister, target EventListerCreator, ) error
Update updates the provided database with records from the Police RSS feed on an interval given by refreshTime.