kit: Index | Files

package booking

import ""

Package booking provides the use-case of booking a cargo. Used by views facing an administrator.


Package Files

endpoint.go instrumenting.go logging.go service.go transport.go


var ErrInvalidArgument = errors.New("invalid argument")

ErrInvalidArgument is returned when one or more arguments are invalid.

func MakeHandler Uses

func MakeHandler(bs Service, logger kitlog.Logger) http.Handler

MakeHandler returns a handler for the booking service.

type Cargo Uses

type Cargo struct {
    ArrivalDeadline time.Time   `json:"arrival_deadline"`
    Destination     string      `json:"destination"`
    Legs            []cargo.Leg `json:"legs,omitempty"`
    Misrouted       bool        `json:"misrouted"`
    Origin          string      `json:"origin"`
    Routed          bool        `json:"routed"`
    TrackingID      string      `json:"tracking_id"`

Cargo is a read model for booking views.

type Location Uses

type Location struct {
    UNLocode string `json:"locode"`
    Name     string `json:"name"`

Location is a read model for booking views.

type Service Uses

type Service interface {
    // BookNewCargo registers a new cargo in the tracking system, not yet
    // routed.
    BookNewCargo(origin location.UNLocode, destination location.UNLocode, deadline time.Time) (cargo.TrackingID, error)

    // LoadCargo returns a read model of a cargo.
    LoadCargo(id cargo.TrackingID) (Cargo, error)

    // RequestPossibleRoutesForCargo requests a list of itineraries describing
    // possible routes for this cargo.
    RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Itinerary

    // AssignCargoToRoute assigns a cargo to the route specified by the
    // itinerary.
    AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) error

    // ChangeDestination changes the destination of a cargo.
    ChangeDestination(id cargo.TrackingID, destination location.UNLocode) error

    // Cargos returns a list of all cargos that have been booked.
    Cargos() []Cargo

    // Locations returns a list of registered locations.
    Locations() []Location

Service is the interface that provides booking methods.

func NewInstrumentingService Uses

func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service

NewInstrumentingService returns an instance of an instrumenting Service.

func NewLoggingService Uses

func NewLoggingService(logger log.Logger, s Service) Service

NewLoggingService returns a new instance of a logging Service.

func NewService Uses

func NewService(cargos cargo.Repository, locations location.Repository, events cargo.HandlingEventRepository, rs routing.Service) Service

NewService creates a booking service with necessary dependencies.

Package booking imports 14 packages (graph) and is imported by 38 packages. Updated 2019-04-24. Refresh now. Tools for package owners.