ttss

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStatusCode    = errors.New("got non 200 status code")
	ErrStopNotFound  = errors.New("stop not found")
	ErrRequestFailed = errors.New("request failed")
)
View Source
var (
	BusEndpoint = Endpoint{
		URL:  "http://91.223.13.70",
		Type: pb.Endpoint_BUS,
	}
	TramEndpoint = Endpoint{
		URL:  "http://185.70.182.51",
		Type: pb.Endpoint_TRAM,
	}

	KrkStopsEndpoints = []Endpointer{
		BusEndpoint,
		TramEndpoint,
	}
)

Functions

func GetAllStops

func GetAllStops(e []Endpointer) (chan []pb.Stop, chan error)

GetAllStops returns stops from multiple endpoints. When one endpoint fails, valid stops are returned and error is send via chan. When request is finished, error channel is closed.

func GetDepartures

func GetDepartures(e []Endpointer, shortName uint) (chan []pb.Departure, chan error)

GetDepartures for range of endpoints. When one endpoint fails, valid departures are returned and error is send via chan. When request is finished, error channel is closed.

Types

type Endpoint

type Endpoint struct {
	URL  string
	Type pb.Endpoint
}

func (Endpoint) GetAllStops

func (e Endpoint) GetAllStops() ([]pb.Stop, error)

GetAllStops fetches Stops from given endpoint.

func (Endpoint) GetDepartures

func (e Endpoint) GetDepartures(id uint) ([]pb.Departure, error)

GetDepartures from Endpoint for stop with given shortName.

func (Endpoint) Id

func (e Endpoint) Id() string

type Endpointer

type Endpointer interface {
	GetDepartures(uint) ([]pb.Departure, error)
	GetAllStops() ([]pb.Stop, error)
	Id() string
}

Jump to

Keyboard shortcuts

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