Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTrackNotFound is returned if a request did not result in a TrackMeta ErrTrackNotFound = errors.New("track not found") // ErrTrackAlreadyExists is returned to request to add a track which // already exists ErrTrackAlreadyExists = errors.New("track already exists") )
var ( // ErrWebhookNotFound is returned if a request did not result in a webhook ErrWebhookNotFound = errors.New("webhook not found") // ErrWebhookAlreadyExists is returned to request to add a webhook which // already exists ErrWebhookAlreadyExists = errors.New("webhook already exists") )
var ( // ErrNoTracksFound symbolizes that there are no tracks to report the // timestamp on ErrNoTracksFound = errors.New("no tracks meeting criteria found") )
Functions ¶
This section is empty.
Types ¶
type DiscordMsg ¶
type DiscordMsg struct {
Content string `json:"content"`
}
DiscordMsg is a webhook message that can be sent to discord
func NewDiscordMsg ¶
NewDiscordMsg creates a new discord message using a template
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server distributes request to a pool of worker gorutines
type Ticker ¶
type Ticker interface { Latest() *time.Time Reporter(latest time.Time) GetReport(limit int) (TickerReport, error) GetReportAfter(timestamp time.Time, limit int) (TickerReport, error) }
Ticker is a generic interface for any type which can act as a ticker
type TickerDB ¶
type TickerDB struct {
// contains filtered or unexported fields
}
TickerDB is a database-aware ticker instance
func NewTickerDB ¶
NewTickerDB creates a new database-aware ticker instance
func (*TickerDB) GetReport ¶
func (t *TickerDB) GetReport(limit int) (rep TickerReport, err error)
GetReport returns a report of the oldest registered timestamps with the given limit
func (*TickerDB) GetReportAfter ¶
GetReportAfter returns a report after a specified time with the given limit
type TickerReport ¶
type TickerReport struct { Latest time.Time `json:"t_latest"` Start time.Time `json:"t_start"` End time.Time `json:"t_stop"` Tracks []TrackID `json:"tracks"` Processing time.Duration `json:"processing"` }
TickerReport encompasses the report the ticker provides to the user
{ "t_latest": <latest added timestamp>, "t_start": <the first timestamp of the added track>, "t_stop": <the last timestamp of the added track>, "tracks": [<id1>, <id2>, ...], "processing": <time in ms of how long it took to process the request> }
type TrackMeta ¶
type TrackMeta struct { ID TrackID `json:"-" bson:"id"` Timestamp time.Time `json:"-" bson:"timestamp"` Date time.Time `json:"H_date" bson:"H_date"` Pilot string `json:"pilot" bson:"pilot"` Glider string `json:"glider" bson:"glider"` GliderID string `json:"glider_id" bson:"glider_id"` TrackLength float64 `json:"track_length" bson:"track_length"` TrackSrcURL string `json:"track_src_url" bson:"track_src_url"` }
TrackMeta contains a subset of metainformation about a igc-track
func TrackMetaFrom ¶
TrackMetaFrom converts a igc.Track into a TrackMeta struct
type TrackMetas ¶
type TrackMetas interface { Get(id TrackID) (TrackMeta, error) Append(meta TrackMeta) error GetAllIDs() ([]TrackID, error) }
TrackMetas is a interface for all storages containing TrackMeta
type TrackMetasDB ¶
type TrackMetasDB struct {
// contains filtered or unexported fields
}
TrackMetasDB contains a map to many TrackMeta objects which are protected by a RWMutex and indexed by a unique id
func NewTrackMetasDB ¶
func NewTrackMetasDB(session *mgo.Session) TrackMetasDB
NewTrackMetasDB creates a new mutex and mapping from ID to TrackMeta
func (*TrackMetasDB) Append ¶
func (metas *TrackMetasDB) Append(meta TrackMeta) (err error)
Append appends a track meta and returns the given id
func (*TrackMetasDB) Get ¶
func (metas *TrackMetasDB) Get(id TrackID) (meta TrackMeta, err error)
Get fetches the track meta of a specific id if it exists
func (*TrackMetasDB) GetAllIDs ¶
func (metas *TrackMetasDB) GetAllIDs() (ids []TrackID, err error)
GetAllIDs fetches all the stored ids
type TrackRegRequest ¶
type TrackRegRequest struct {
URLstr string `json:"url"`
}
TrackRegRequest is the format of a track registration request
type WebhookID ¶
type WebhookID uint32
WebhookID is a unique id for a track
func NewWebhookID ¶
NewWebhookID creates a new unique track ID
type WebhookInfo ¶
type WebhookInfo struct { ID WebhookID `json:"-" bson:"id"` URLstr string `json:"webhookURL" bson:"webhookURL"` TriggerRate uint `json:"minTriggerValue" bson:"minTriggerValue"` LastTriggered time.Time `json:"-" bson:"lastTriggered"` }
WebhookInfo contains information about a webhook
type Webhooks ¶
type Webhooks interface { Trigger() Get(id WebhookID) (WebhookInfo, error) Append(webhook WebhookInfo) error Delete(id WebhookID) (WebhookInfo, error) }
Webhooks is a interface for all storages containing WebhookInfo
type WebhooksDB ¶
type WebhooksDB struct {
// contains filtered or unexported fields
}
WebhooksDB contains a map to many WebhookInfo objects which are protected by a RWMutex and indexed by a unique id
func NewWebhooksDB ¶
func NewWebhooksDB(session *mgo.Session, httpClient *http.Client) WebhooksDB
NewWebhooksDB creates a new mutex and mapping from ID to WebhookInfo
func (*WebhooksDB) Append ¶
func (db *WebhooksDB) Append(webhook WebhookInfo) (err error)
Append appends a track webhook and returns the given id
func (*WebhooksDB) Delete ¶
func (db *WebhooksDB) Delete(id WebhookID) (webhook WebhookInfo, err error)
Delete removes a webhook
func (*WebhooksDB) Get ¶
func (db *WebhooksDB) Get(id WebhookID) (webhook WebhookInfo, err error)
Get fetches the track webhook of a specific id if it exists
func (*WebhooksDB) Trigger ¶
func (db *WebhooksDB) Trigger()
Trigger returns a channel to trigger webhooks based on the number of tracks