ttss

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK               = iota
	OTHER_ERROR      // Please check logs for detailed error
	REQUEST_FAILED   // Request failed
	REQUEST_NON_200  // Request returned non 200 status code
	EMPTY_DEPARTURES // No departures received (with 200 status code)
	STOP_NOT_FOUND   // Stop was not found
)

Errors below are sorted by severity - we care the most on the request that succeded, but returned no departures

Variables

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 added in v0.2.0

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.

func GetDeparturesErrorCode added in v0.2.0

func GetDeparturesErrorCode(e Endpointer, id uint) (errorCode int)

GetDeparturesErrorCode returns error that can be consumed by e.g. Prometheus.

Types

type Endpoint

type Endpoint struct {
	URL  string
	Type pb.Endpoint
}

func (Endpoint) GetAllStops added in v0.2.0

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

GetAllStops fetches Stops from given endpoint.

func (Endpoint) GetDepartures added in v0.2.0

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

GetDepartures from Endpoint for stop with given shortName.

func (Endpoint) Id added in v0.2.0

func (e Endpoint) Id() string

type Endpointer added in v0.2.0

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

type ErrRequestFailed added in v0.2.0

type ErrRequestFailed struct {
	// contains filtered or unexported fields
}

func (ErrRequestFailed) Error added in v0.2.0

func (e ErrRequestFailed) Error() string

type ErrStatusCode added in v0.2.0

type ErrStatusCode struct {
	// contains filtered or unexported fields
}

func (ErrStatusCode) Error added in v0.2.0

func (e ErrStatusCode) Error() string

type ErrStopNotFound added in v0.4.0

type ErrStopNotFound struct {
}

func (ErrStopNotFound) Error added in v0.4.0

func (e ErrStopNotFound) Error() string

Jump to

Keyboard shortcuts

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