voyage.go 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package model
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. // VoyageNumber uniquely identifies a particular Voyage.
  7. type VoyageNumber string
  8. // Voyage is a uniquely identifiable series of carrier movements.
  9. type Voyage struct {
  10. VoyageNumber VoyageNumber
  11. Schedule Schedule
  12. }
  13. // NewVoyage creates a voyage with a voyage number and a provided schedule.
  14. func NewVoyage(n VoyageNumber, s Schedule) *Voyage {
  15. return &Voyage{VoyageNumber: n, Schedule: s}
  16. }
  17. // Schedule describes a voyage schedule.
  18. type Schedule struct {
  19. CarrierMovements []CarrierMovement
  20. }
  21. // CarrierMovement is a vessel voyage from one location to another.
  22. type CarrierMovement struct {
  23. DepartureLocation UNLocode
  24. ArrivalLocation UNLocode
  25. DepartureTime time.Time
  26. ArrivalTime time.Time
  27. }
  28. // ErrUnknownVoyage is used when a voyage could not be found.
  29. var ErrUnknownVoyage = errors.New("unknown voyage")
  30. // VoyageRepository provides access a voyage store.
  31. type VoyageRepository interface {
  32. Find(VoyageNumber) (*Voyage, error)
  33. }