Versions in this module Expand all Collapse all v0 v0.0.4 Dec 16, 2020 Changes in this version + const EmailFailed + const EmailPending + const KmlGzipContentType + const KmlPlainTextContentType + func CheckRowsUpdated(res sql.Result, expectAffected int64) error + func IsUniqueConstraintViolation(err error) (bool, error) + type Aircraft struct + CreatedAt time.Time + ID uint64 + Icao string + UpdatedAt time.Time + type Database interface + CloseSession func(session *Session, closedAt time.Time) (sql.Result, error) + CloseSightingBatch func(sightings []*Sighting, closedAt time.Time) error + CreateAircraft func(icao string, firstSeenTime time.Time) (sql.Result, error) + CreateEmailJobTx func(tx *sqlx.Tx, createdAt time.Time, content []byte) (sql.Result, error) + CreateNewSightingCallSignTx func(tx *sqlx.Tx, sighting *Sighting, callsign string, observedAt time.Time) (sql.Result, error) + CreateNewSightingSquawkTx func(tx *sqlx.Tx, sighting *Sighting, squawk string, observedAt time.Time) (sql.Result, error) + CreateProject func(projectName string, now time.Time) (sql.Result, error) + CreateSession func(project *Project, identifier string, withSquawks bool, withTxTypes bool, ...) (sql.Result, error) + CreateSighting func(session *Session, ac *Aircraft, firstSeenTime time.Time) (sql.Result, error) + CreateSightingKmlContent func(sighting *Sighting, kmlData []byte) (sql.Result, error) + CreateSightingLocation func(sightingID uint64, t time.Time, altitude int64, lat float64, long float64) (sql.Result, error) + CreateSightingLocationTx func(tx *sqlx.Tx, sightingID uint64, t time.Time, altitude int64, lat float64, ...) (sql.Result, error) + CreateSightingTx func(tx *sqlx.Tx, session *Session, ac *Aircraft, firstSeenTime time.Time) (sql.Result, error) + DeleteCompletedEmailTx func(tx *sqlx.Tx, job Email) (sql.Result, error) + GetAircraftByID func(id uint64) (*Aircraft, error) + GetAircraftByIcao func(icao string) (*Aircraft, error) + GetFullLocationHistory func(sighting *Sighting, batchSize int64) ([]SightingLocation, error) + GetLastSighting func(session *Session, ac *Aircraft) (*Sighting, error) + GetLastSightingTx func(tx *sqlx.Tx, session *Session, ac *Aircraft) (*Sighting, error) + GetPendingEmailJobs func(currentTime time.Time) ([]Email, error) + GetProject func(projectName string) (*Project, error) + GetSessionByIdentifier func(project *Project, identifier string) (*Session, error) + GetSightingByID func(sightingID uint64) (*Sighting, error) + GetSightingByIDTx func(tx *sqlx.Tx, sightingID uint64) (*Sighting, error) + GetSightingKml func(sighting *Sighting) (*SightingKml, error) + LoadLocationHistory func(sighting *Sighting, lastID int64, batchSize int64) (*sqlx.Rows, error) + MarkEmailFailedTx func(tx *sqlx.Tx, job *Email) (sql.Result, error) + ReopenSighting func(sighting *Sighting) (sql.Result, error) + ReopenSightingTx func(tx *sqlx.Tx, sighting *Sighting) (sql.Result, error) + RetryEmailAfterTx func(tx *sqlx.Tx, job *Email, retryAfter time.Time) (sql.Result, error) + Transaction func(f func(tx *sqlx.Tx) error) error + UpdateSightingCallsignTx func(tx *sqlx.Tx, sighting *Sighting, callsign string) (sql.Result, error) + UpdateSightingKml func(sightingKml *SightingKml) (sql.Result, error) + UpdateSightingSquawkTx func(tx *sqlx.Tx, sighting *Sighting, squawk string) (sql.Result, error) + WalkLocationHistoryBatch func(sighting *Sighting, batchSize int64, f func([]SightingLocation)) error + type DatabaseImpl struct + func NewDatabase(db *sqlx.DB, dialect goqu.DialectWrapper) *DatabaseImpl + func (d *DatabaseImpl) CloseSession(session *Session, closedAt time.Time) (sql.Result, error) + func (d *DatabaseImpl) CloseSightingBatch(sightings []*Sighting, closedAt time.Time) error + func (d *DatabaseImpl) CreateAircraft(icao string, firstSeenTime time.Time) (sql.Result, error) + func (d *DatabaseImpl) CreateEmailJobTx(tx *sqlx.Tx, createdAt time.Time, content []byte) (sql.Result, error) + func (d *DatabaseImpl) CreateNewSightingCallSignTx(tx *sqlx.Tx, sighting *Sighting, callsign string, observedAt time.Time) (sql.Result, error) + func (d *DatabaseImpl) CreateNewSightingSquawkTx(tx *sqlx.Tx, sighting *Sighting, squawk string, observedAt time.Time) (sql.Result, error) + func (d *DatabaseImpl) CreateProject(name string, now time.Time) (sql.Result, error) + func (d *DatabaseImpl) CreateSession(project *Project, identifier string, withSquawks bool, withTxTypes bool, ...) (sql.Result, error) + func (d *DatabaseImpl) CreateSighting(session *Session, ac *Aircraft, firstSeenTime time.Time) (sql.Result, error) + func (d *DatabaseImpl) CreateSightingKmlContent(sighting *Sighting, kmlData []byte) (sql.Result, error) + func (d *DatabaseImpl) CreateSightingLocation(sightingID uint64, t time.Time, altitude int64, lat float64, long float64) (sql.Result, error) + func (d *DatabaseImpl) CreateSightingLocationTx(tx *sqlx.Tx, sightingID uint64, t time.Time, altitude int64, lat float64, ...) (sql.Result, error) + func (d *DatabaseImpl) CreateSightingTx(tx *sqlx.Tx, session *Session, ac *Aircraft, firstSeenTime time.Time) (sql.Result, error) + func (d *DatabaseImpl) DeleteCompletedEmailTx(tx *sqlx.Tx, job Email) (sql.Result, error) + func (d *DatabaseImpl) GetAircraftByID(id uint64) (*Aircraft, error) + func (d *DatabaseImpl) GetAircraftByIcao(icao string) (*Aircraft, error) + func (d *DatabaseImpl) GetFullLocationHistory(sighting *Sighting, batchSize int64) ([]SightingLocation, error) + func (d *DatabaseImpl) GetLastSighting(session *Session, ac *Aircraft) (*Sighting, error) + func (d *DatabaseImpl) GetLastSightingCallSignTx(tx *sqlx.Tx, sighting *Sighting) (*SightingCallSign, error) + func (d *DatabaseImpl) GetLastSightingSquawkTx(tx *sqlx.Tx, sighting *Sighting) (*SightingSquawk, error) + func (d *DatabaseImpl) GetLastSightingTx(tx *sqlx.Tx, session *Session, ac *Aircraft) (*Sighting, error) + func (d *DatabaseImpl) GetPendingEmailJobs(now time.Time) ([]Email, error) + func (d *DatabaseImpl) GetProject(name string) (*Project, error) + func (d *DatabaseImpl) GetSchemaMigration() (*SchemaMigrations, error) + func (d *DatabaseImpl) GetSessionByIdentifier(project *Project, identifier string) (*Session, error) + func (d *DatabaseImpl) GetSightingByID(sightingID uint64) (*Sighting, error) + func (d *DatabaseImpl) GetSightingByIDTx(tx *sqlx.Tx, sightingID uint64) (*Sighting, error) + func (d *DatabaseImpl) GetSightingKml(sighting *Sighting) (*SightingKml, error) + func (d *DatabaseImpl) LoadLocationHistory(sighting *Sighting, lastID int64, batchSize int64) (*sqlx.Rows, error) + func (d *DatabaseImpl) MarkEmailFailedTx(tx *sqlx.Tx, job *Email) (sql.Result, error) + func (d *DatabaseImpl) ReopenSighting(sighting *Sighting) (sql.Result, error) + func (d *DatabaseImpl) ReopenSightingTx(tx *sqlx.Tx, sighting *Sighting) (sql.Result, error) + func (d *DatabaseImpl) RetryEmailAfterTx(tx *sqlx.Tx, job *Email, retryAfter time.Time) (sql.Result, error) + func (d *DatabaseImpl) Transaction(f func(tx *sqlx.Tx) error) error + func (d *DatabaseImpl) UpdateSightingCallsignTx(tx *sqlx.Tx, sighting *Sighting, callsign string) (sql.Result, error) + func (d *DatabaseImpl) UpdateSightingKml(sightingKml *SightingKml) (sql.Result, error) + func (d *DatabaseImpl) UpdateSightingSquawkTx(tx *sqlx.Tx, sighting *Sighting, squawk string) (sql.Result, error) + func (d *DatabaseImpl) WalkLocationHistoryBatch(sighting *Sighting, batchSize int64, f func([]SightingLocation)) error + type Email struct + CreatedAt time.Time + ID uint64 + Job []byte + Retries int32 + RetryAfter *time.Time + Status int32 + UpdatedAt time.Time + type Project struct + CreatedAt time.Time + DeletedAt *time.Time + ID uint64 + Identifier string + Label *string + UpdatedAt time.Time + type SchemaMigrations struct + Dirty bool + Version uint64 + type Session struct + ClosedAt *time.Time + CreatedAt time.Time + DeletedAt *time.Time + ID uint64 + Identifier string + ProjectID uint64 + UpdatedAt time.Time + WithCallSigns bool + WithSquawks bool + WithTransmissionTypes bool + type Sighting struct + AircraftID uint64 + CallSign *string + ClosedAt *time.Time + CreatedAt time.Time + ID uint64 + ProjectID uint64 + SessionID uint64 + Squawk *string + TransmissionTypes uint8 + UpdatedAt time.Time + type SightingCallSign struct + CallSign string + ID uint64 + ObservedAt time.Time + SightingID uint64 + type SightingKml struct + ContentType int32 + ID uint64 + Kml []byte + SightingID uint64 + func (k *SightingKml) DecodedKml() ([]byte, error) + func (k *SightingKml) UpdateKml(kml []byte) error + type SightingLocation struct + Altitude int64 + ID uint64 + Latitude float64 + Longitude float64 + SightingID uint64 + TimeStamp time.Time + type SightingSquawk struct + ID uint64 + ObservedAt time.Time + SightingID uint64 + Squawk string + type TxExecer struct + func NewTxExecer(db *sqlx.DB, f func(tx *sqlx.Tx) error) *TxExecer + func (e *TxExecer) Exec() error