domain

package
v0.0.0-...-1e04dac Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBikeInUse  = errors.New("bike already in use")
	ErrEmptyBody  = errors.New("empty body")
	ErrUnexpected = errors.New("unexpected error")
)

Domain based errors.

Functions

func DeserializeBikeFromResponse

func DeserializeBikeFromResponse(resp *http.Response) (*models.Bike, error)

DeserializeBikeFromResponse tries to extract a bike for an http Response.

func DeserializeBikesFromResponse

func DeserializeBikesFromResponse(resp *http.Response) ([]models.Bike, error)

DeserializeBikesFromResponse tries to extract an array of bikes for an http Response.

func DeserializeTripFromResponse

func DeserializeTripFromResponse(resp *http.Response) (*models.Trip, error)

DeserializeTripFromResponse tries to extract a trip for an http Response.

func EndTrip

func EndTrip(ctx context.Context, tripID string, lat, lng float64) (*models.Trip, error)

EndTrip unsuprisingly starts a trip when possible.

func EndTripFromGateway

func EndTripFromGateway(ctx context.Context, conf configuration.GatewayConfiguration, tripID string, lat, lng float64) (*models.Trip, error)

EndTripFromGateway calls the trip service to end a trip.

func GatewayEndTrip

func GatewayEndTrip(ctx context.Context, conf configuration.GatewayConfiguration, tripID string, lat, lng float64) (*models.Trip, error)

GatewayEndTrip unsuprisingly starts a trip when possible.

func GatewayGetBikeByID

func GatewayGetBikeByID(ctx context.Context, conf configuration.GatewayConfiguration, bikeID string) (*models.Bike, error)

GatewayGetBikeByID returns a bike given an valid ID.

func GatewayListOfBikes

func GatewayListOfBikes(ctx context.Context, conf configuration.GatewayConfiguration, cursor string, limit int64) ([]models.Bike, error)

GatewayListOfBikes lists bikes with pagination.

func GatewayStartTrip

func GatewayStartTrip(ctx context.Context, conf configuration.GatewayConfiguration, bikeID string,
	lat, lng float64) (*models.Trip, error)

GatewayStartTrip unsuprisingly starts a trip when possible.

func GetBikeByID

func GetBikeByID(ctx context.Context, bikeID string) (*models.Bike, error)

GetBikeByID returns a bike given an valid ID.

func ListOfBikes

func ListOfBikes(ctx context.Context, cursor string, limit int64) ([]models.Bike, error)

ListOfBikes lists bikes with pagination.

func ListenerToBikeEvent

func ListenerToBikeEvent(ctx context.Context, conf configuration.BikeConfiguration,
	logger logging.Logger, database storage.BikeStore) (messaging.Consumer, error)

ListenerToBikeEvent for bike events.

func ListenerToTripEvent

func ListenerToTripEvent(ctx context.Context, conf configuration.TripConfiguration,
	logger logging.Logger, database storage.TripStore) (messaging.Consumer, error)

ListenerToTripEvent for trip events.

func LockBikeByID

func LockBikeByID(ctx context.Context, bikeID string) (*models.Bike, error)

LockBikeByID locks a bike given an valid ID.

func LockBikeFromGateway

func LockBikeFromGateway(ctx context.Context, conf configuration.GatewayConfiguration, bikeID string) (*models.Bike, error)

LockBikeFromGateway locks a bike.

func PopulateDatabase

func PopulateDatabase(ctx context.Context, db storage.BikeStore) error

PopulateDatabase put stuff in Database if empty

func StartTrip

func StartTrip(ctx context.Context, bikeID string,
	lat, lng float64) (*models.Trip, error)

StartTrip unsuprisingly starts a trip when possible.

func StartTripFromGateway

func StartTripFromGateway(ctx context.Context, conf configuration.GatewayConfiguration, bikeID string, lat, lng float64) (*models.Trip, error)

StartTripFromGateway calls the trip service to start a trip.

func TrackTrip

func TrackTrip(ctx context.Context,
	messenger messaging.Emitter, hearbeat TrackTripPayload) error

TrackTrip sends a payload through the messaging pipeline.

func UnLockBikeByID

func UnLockBikeByID(ctx context.Context, bikeID string) (*models.Bike, error)

UnLockBikeByID unlocks a bike given an valid ID.

func UnLockBikeFromGateway

func UnLockBikeFromGateway(ctx context.Context, conf configuration.GatewayConfiguration, bikeID string) error

UnLockBikeFromGateway unlocks a bike.

Types

type EndTripPayload

type EndTripPayload struct {
	TripID   string   `json:"trip_id"`
	Location Location `json:"location"`
}

EndTripPayload specifies the expected http body for ending a trip.

type Location

type Location struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

Location specifies location model.

type StartTripPayload

type StartTripPayload struct {
	BikeID   string   `json:"bike_id"`
	Location Location `json:"location"`
}

StartTripPayload specifies the expected http body for starting a trip.

type TrackTripPayload

type TrackTripPayload struct {
	Lng, Lat float64
	BikeID   string
	TripID   string
}

TrackTripPayload for messaging.

Jump to

Keyboard shortcuts

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