Splitting design into separate services
This commit is contained in:
44
services/inventory/design/design.go
Normal file
44
services/inventory/design/design.go
Normal file
@ -0,0 +1,44 @@
|
||||
package design
|
||||
|
||||
import (
|
||||
. "goa.design/goa/v3/dsl"
|
||||
)
|
||||
|
||||
var _ = API("inventory", func() {
|
||||
Title("Inventory Service")
|
||||
Server("inventory", func() {
|
||||
Host("localhost", func() {
|
||||
URI("grpc://localhost:8081")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Service("inventory", func() {
|
||||
Description("A GRPC back service that handles CRUD operations for the characters’ inventories")
|
||||
// Method("listItems", func() {
|
||||
// })
|
||||
|
||||
Method("addItem", func() {
|
||||
Payload(Int)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
GRPC(func() {
|
||||
Response(CodeOK)
|
||||
})
|
||||
})
|
||||
|
||||
Method("removeItem", func() {
|
||||
Payload(Int)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
GRPC(func() {
|
||||
Response(CodeOK)
|
||||
Response("NotFound", CodeNotFound)
|
||||
Response("BadRequest", CodeInvalidArgument)
|
||||
})
|
||||
})
|
||||
})
|
30
services/inventory/inventory.go
Normal file
30
services/inventory/inventory.go
Normal file
@ -0,0 +1,30 @@
|
||||
package inventoryapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
inventory "crossnokaye-interview-assignment/services/inventory/gen/inventory"
|
||||
"log"
|
||||
)
|
||||
|
||||
// inventory service example implementation.
|
||||
// The example methods log the requests and return zero values.
|
||||
type inventorysrvc struct {
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
// NewInventory returns the inventory service implementation.
|
||||
func NewInventory(logger *log.Logger) inventory.Service {
|
||||
return &inventorysrvc{logger}
|
||||
}
|
||||
|
||||
// AddItem implements addItem.
|
||||
func (s *inventorysrvc) AddItem(ctx context.Context, p int) (err error) {
|
||||
s.logger.Print("inventory.addItem")
|
||||
return
|
||||
}
|
||||
|
||||
// RemoveItem implements removeItem.
|
||||
func (s *inventorysrvc) RemoveItem(ctx context.Context, p int) (err error) {
|
||||
s.logger.Print("inventory.removeItem")
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user