OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-kit / kit / examples / shipping / voyage / voyage.go
1 // Package voyage provides the Voyage aggregate.
2 package voyage
3
4 import (
5         "errors"
6         "time"
7
8         "github.com/go-kit/kit/examples/shipping/location"
9 )
10
11 // Number uniquely identifies a particular Voyage.
12 type Number string
13
14 // Voyage is a uniquely identifiable series of carrier movements.
15 type Voyage struct {
16         Number   Number
17         Schedule Schedule
18 }
19
20 // New creates a voyage with a voyage number and a provided schedule.
21 func New(n Number, s Schedule) *Voyage {
22         return &Voyage{Number: n, Schedule: s}
23 }
24
25 // Schedule describes a voyage schedule.
26 type Schedule struct {
27         CarrierMovements []CarrierMovement
28 }
29
30 // CarrierMovement is a vessel voyage from one location to another.
31 type CarrierMovement struct {
32         DepartureLocation location.UNLocode
33         ArrivalLocation   location.UNLocode
34         DepartureTime     time.Time
35         ArrivalTime       time.Time
36 }
37
38 // ErrUnknown is used when a voyage could not be found.
39 var ErrUnknown = errors.New("unknown voyage")
40
41 // Repository provides access a voyage store.
42 type Repository interface {
43         Find(Number) (*Voyage, error)
44 }