forked from marcusolsson/goddd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voyage.go
41 lines (33 loc) · 1007 Bytes
/
voyage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package shipping
import (
"errors"
"time"
)
// VoyageNumber uniquely identifies a particular Voyage.
type VoyageNumber string
// Voyage is a uniquely identifiable series of carrier movements.
type Voyage struct {
VoyageNumber VoyageNumber
Schedule Schedule
}
// NewVoyage creates a voyage with a voyage number and a provided schedule.
func NewVoyage(n VoyageNumber, s Schedule) *Voyage {
return &Voyage{VoyageNumber: n, Schedule: s}
}
// Schedule describes a voyage schedule.
type Schedule struct {
CarrierMovements []CarrierMovement
}
// CarrierMovement is a vessel voyage from one location to another.
type CarrierMovement struct {
DepartureLocation UNLocode
ArrivalLocation UNLocode
DepartureTime time.Time
ArrivalTime time.Time
}
// ErrUnknownVoyage is used when a voyage could not be found.
var ErrUnknownVoyage = errors.New("unknown voyage")
// VoyageRepository provides access a voyage store.
type VoyageRepository interface {
Find(VoyageNumber) (*Voyage, error)
}