Splitting design into separate services

This commit is contained in:
Brandon Watson
2023-08-10 13:14:38 -05:00
parent 2f149f2c6d
commit 54c2632cec
15 changed files with 699 additions and 235 deletions

View 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)
})
})
})

View 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
}