Documentation ¶
Overview ¶
Package pathgtfsrt contains a GTFS realtime feed generator for the PATH train.
Index ¶
- Constants
- Variables
- type Destination
- type Feed
- type GrpcSourceClient
- func (client *GrpcSourceClient) Close() error
- func (client *GrpcSourceClient) GetRouteToRouteId(ctx context.Context) (routeToRouteId map[sourceapi.Route]string, err error)
- func (client *GrpcSourceClient) GetStationToStopId(ctx context.Context) (stationToStopId map[sourceapi.Station]string, err error)
- func (client *GrpcSourceClient) GetTrainsAtStation(ctx context.Context, station sourceapi.Station) ([]Train, error)
- type HttpClient
- type HttpSourceClient
- func (client *HttpSourceClient) GetRouteToRouteId(_ context.Context) (map[sourceapi.Route]string, error)
- func (client *HttpSourceClient) GetStationToStopId(_ context.Context) (map[sourceapi.Station]string, error)
- func (client *HttpSourceClient) GetTrainsAtStation(_ context.Context, station sourceapi.Station) ([]Train, error)
- type Message
- type PaNyNjClient
- func (client *PaNyNjClient) GetRouteToRouteId(_ context.Context) (map[sourceapi.Route]string, error)
- func (client *PaNyNjClient) GetStationToStopId(_ context.Context) (map[sourceapi.Station]string, error)
- func (client *PaNyNjClient) GetTrainsAtStation(_ context.Context, station sourceapi.Station) ([]Train, error)
- type Result
- type RidePathResponse
- type SourceClient
- type Train
- type UpdateCallback
Constants ¶
const (
ViaHobokenSuffix = "via hoboken"
)
Variables ¶
var BuildNumber string
Set via flags on Go build
Functions ¶
This section is empty.
Types ¶
type Destination ¶
Destination is a labeled direction with associated trains
type Feed ¶
type Feed struct {
// contains filtered or unexported fields
}
Feed periodically generates GTFS Realtime data for the PATH train and makes it available through the `Get` method.
Feed also satisfies the http.Handler interface, and simply responds to all requests with the most recent GTFS realtime data.
func NewFeed ¶
func NewFeed(ctx context.Context, clock clock.Clock, updatePeriod time.Duration, sourceClient SourceClient, callback UpdateCallback) (*Feed, error)
NewFeed creates a new feed.
This function gets static and realtime data from the source API and creates the first version of the GTFS realtime feed before returning. It then, in the background, periodically updates the realtime data following the provided update period.
After each update, including the first synchronous update, the provided callback is invoked.
type GrpcSourceClient ¶
type GrpcSourceClient struct {
// contains filtered or unexported fields
}
GrpcSourceClient is a source client that gets data using the Razza gRPC API.
func NewGrpcSourceClient ¶
func NewGrpcSourceClient(timeoutPeriod time.Duration) (*GrpcSourceClient, error)
func (*GrpcSourceClient) Close ¶
func (client *GrpcSourceClient) Close() error
func (*GrpcSourceClient) GetRouteToRouteId ¶
func (*GrpcSourceClient) GetStationToStopId ¶
func (*GrpcSourceClient) GetTrainsAtStation ¶
type HttpSourceClient ¶
type HttpSourceClient struct {
// contains filtered or unexported fields
}
HttpSourceClient is a source client that gets data using the Razza HTTP API.
func NewHttpSourceClient ¶
func NewHttpSourceClient(httpClient HttpClient) *HttpSourceClient
func (*HttpSourceClient) GetRouteToRouteId ¶
func (*HttpSourceClient) GetStationToStopId ¶
func (*HttpSourceClient) GetTrainsAtStation ¶
type Message ¶
type Message struct { Target string `json:"target"` SecondsToArrival string `json:"secondsToArrival"` ArrivalTimeMessage string `json:"arrivalTimeMessage"` LineColor string `json:"lineColor"` HeadSign string `json:"headSign"` LastUpdated string `json:"lastUpdated"` }
Message contains information about a single train
type PaNyNjClient ¶
type PaNyNjClient struct {
// contains filtered or unexported fields
}
PaNyNjClient is a source client that gets data from the Port Authority of New York and New Jersey. It is what is used to power the official realtime schedules on the PATH website: https://www.panynj.gov/path/en/index.html
func NewPaNyNjSourceClient ¶
func NewPaNyNjSourceClient(httpClient HttpClient, clock clock.Clock) *PaNyNjClient
func (*PaNyNjClient) GetRouteToRouteId ¶
func (*PaNyNjClient) GetStationToStopId ¶
func (*PaNyNjClient) GetTrainsAtStation ¶
type Result ¶
type Result struct { ConsideredStation string `json:"consideredStation"` Destinations []Destination `json:"destinations"` }
Result represents all destinations for a given station
type RidePathResponse ¶
type RidePathResponse struct {
Results []Result `json:"results"`
}
RidePathResponse contains information about all incoming trains at all stations
type SourceClient ¶
type SourceClient interface { // Return a map from source API station code to GTFS static stop ID GetStationToStopId(context.Context) (map[sourceapi.Station]string, error) // Return a map from source API route code to GTFS static route ID GetRouteToRouteId(context.Context) (map[sourceapi.Route]string, error) // List all upcoming trains at a station GetTrainsAtStation(context.Context, sourceapi.Station) ([]Train, error) }
SourceClient describes the methods that the feed generator requires from the source API in order to build the feed.
type Train ¶
type Train *sourceapi.GetUpcomingTrainsResponse_UpcomingTrain
Train contains data about a PATH train at a specific station.
type UpdateCallback ¶
type UpdateCallback func(msg *gtfs.FeedMessage, requestErrs []error)
UpdateCallback is the type of callback that the feed runs after each update.
The first argument is the GTFS realtime message that was just built. The second argument is the list of all errors that occured when getting realtime data from the source API.