Moved to google.golang.org/genproto/googleapis/api/annotations
Fixes #52
This commit is contained in:
53
vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go
generated
vendored
Normal file
53
vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Package inspection provides means to inspect cargos.
|
||||
package inspection
|
||||
|
||||
import (
|
||||
"github.com/go-kit/kit/examples/shipping/cargo"
|
||||
)
|
||||
|
||||
// EventHandler provides means of subscribing to inspection events.
|
||||
type EventHandler interface {
|
||||
CargoWasMisdirected(*cargo.Cargo)
|
||||
CargoHasArrived(*cargo.Cargo)
|
||||
}
|
||||
|
||||
// Service provides cargo inspection operations.
|
||||
type Service interface {
|
||||
// InspectCargo inspects cargo and send relevant notifications to
|
||||
// interested parties, for example if a cargo has been misdirected, or
|
||||
// unloaded at the final destination.
|
||||
InspectCargo(id cargo.TrackingID)
|
||||
}
|
||||
|
||||
type service struct {
|
||||
cargos cargo.Repository
|
||||
events cargo.HandlingEventRepository
|
||||
handler EventHandler
|
||||
}
|
||||
|
||||
// TODO: Should be transactional
|
||||
func (s *service) InspectCargo(id cargo.TrackingID) {
|
||||
c, err := s.cargos.Find(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
h := s.events.QueryHandlingHistory(id)
|
||||
|
||||
c.DeriveDeliveryProgress(h)
|
||||
|
||||
if c.Delivery.IsMisdirected {
|
||||
s.handler.CargoWasMisdirected(c)
|
||||
}
|
||||
|
||||
if c.Delivery.IsUnloadedAtDestination {
|
||||
s.handler.CargoHasArrived(c)
|
||||
}
|
||||
|
||||
s.cargos.Store(c)
|
||||
}
|
||||
|
||||
// NewService creates a inspection service with necessary dependencies.
|
||||
func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository, handler EventHandler) Service {
|
||||
return &service{cargos, events, handler}
|
||||
}
|
Reference in New Issue
Block a user