Skip to content

Commit

Permalink
Extend service with GetConsignment method
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeping-barber committed Sep 6, 2018
1 parent 5368c36 commit 536308e
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 33 deletions.
11 changes: 11 additions & 0 deletions consignment-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (

type IRepository interface {
Create(*pb.Consignment) (*pb.Consignment, error)
GetAll() []*pb.Consignment
}

// Dummy repository implementation
Expand All @@ -30,6 +31,10 @@ func (repo *Repository) Create(consignment *pb.Consignment) (*pb.Consignment, er
return consignment, nil
}

func (repo *Repository) GetAll() []*pb.Consignment {
return repo.consignement
}

// Service satisfy all methods from the proto interface
type Service struct {
repo IRepository
Expand All @@ -45,6 +50,12 @@ func (s *Service) CreateConsignment(ctx context.Context, request *pb.Consignment
return &pb.Response{Created: true, Consignment: consignment}, nil
}

func (s *Service) GetConsignment(ctx context.Context) (*pb.Response, error) {
consignments := s.repo.GetAll()

return &pb.Response{Consignments: consignments}, nil
}

func main() {

repo := &Repository{}
Expand Down
139 changes: 107 additions & 32 deletions consignment-service/proto/consignment/consignment.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion consignment-service/proto/consignment/consignment.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package go.micro.srv.consignment;

service ShippingService {
rpc CreateConsignment (Consignment) returns (Response) {}
rpc GetConsignment (GetRequest) returns (Response)
rpc GetConsignment (GetRequest) returns (Response) {}
}

message Consignment {
Expand Down

0 comments on commit 536308e

Please sign in to comment.