alerts

package
v0.0.0-...-70af2fa Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loop

func Loop(client *http.Client, gtfsResource util.Resource, sleepTime time.Duration, opts Options) (err error)

Loop automatically updates the GTFS-RT alerts file

func Make

func Make(client *http.Client, routeMap map[string]sort.StringSlice, opts Options) (err error)

Make auto-magically creates GTFS-Realtime feeds with alert data

Types

type Alert

type Alert struct {
	ID       string   `json:"id"`
	Routes   []string `json:"routes"`
	Effect   string   `json:"effect"`
	Link     string   `json:"link"`
	Title    string   `json:"title"`
	Body     string   `json:"body"`
	HTMLBody string   `json:"htmlbody"`
}

Alert contains an internal representation of an alert, which is also marshallable to JSON

func (*Alert) AsProto

func (a *Alert) AsProto() *gtfsrt.FeedEntity

AsProto returns the Alert marshalled to a GTFS-RT FeedEntity

func (*Alert) LoadExternal

func (a *Alert) LoadExternal(client exclusiveHTTPClient, routeMap map[string]sort.StringSlice) (err error)

LoadExternal processes data located on the website saved in a.Link

type AlertContainer

type AlertContainer struct {
	Timestamp time.Time `json:"-"`
	Time      string    `json:"time"`
	Alerts    []*Alert  `json:"alerts"`
}

AlertContainer is a container for multiple alerts, marshallable to JSON

func (*AlertContainer) AsProto

func (ac *AlertContainer) AsProto() *gtfsrt.FeedMessage

AsProto returns this list of alerts marshalled into a GTFS-RT FeedMessage

func (*AlertContainer) Filter

func (ac *AlertContainer) Filter()

Filter removes all alerts without associated routes

func (*AlertContainer) LoadExternal

func (ac *AlertContainer) LoadExternal(client exclusiveHTTPClient, routeMap map[string]sort.StringSlice, throwErrors bool) error

LoadExternal asynchronously calls LoadExternal on all its alerts

func (*AlertContainer) SaveJSON

func (ac *AlertContainer) SaveJSON(target string) (err error)

SaveJSON marshalls the container into a json file at the given location

func (*AlertContainer) SavePB

func (ac *AlertContainer) SavePB(target string, humanReadable bool) (err error)

SavePB marshalls the container into a GTFS-Realtime protocol buffer file

type Options

type Options struct {
	GtfsRtTarget    string
	JSONTarget      string
	HumanReadable   bool
	ThrowLinkErrors bool
}

Options represents available options for generating alerts

Jump to

Keyboard shortcuts

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