Implemented first pass of character and inventory services

This commit is contained in:
Brandon Watson
2023-08-14 19:22:40 -05:00
parent a9eed6f284
commit 6799b59f9c
9 changed files with 232 additions and 57 deletions

View File

@ -21,14 +21,14 @@ func main() {
// Define command line flags, add any other flag required to configure the
// service.
var (
hostF = flag.String("host", "localhost", "Server host (valid values: localhost)")
domainF = flag.String("domain", "", "Host domain name (overrides host domain specified in service design)")
httpPortF = flag.String("http-port", "", "HTTP port (overrides host HTTP port specified in service design)")
secureF = flag.Bool("secure", false, "Use secure scheme (https or grpcs)")
dbgF = flag.Bool("debug", false, "Log request and response bodies")
itemAddr = flag.String("locator-addr", ":8082", "Item service address")
//characterAddr = flag.String("locator-addr", ":8080", "Item service address")
//inventoryAddr = flag.String("locator-addr", ":8081", "Item service address")
hostF = flag.String("host", "localhost", "Server host (valid values: localhost)")
domainF = flag.String("domain", "", "Host domain name (overrides host domain specified in service design)")
httpPortF = flag.String("http-port", "", "HTTP port (overrides host HTTP port specified in service design)")
secureF = flag.Bool("secure", false, "Use secure scheme (https or grpcs)")
dbgF = flag.Bool("debug", false, "Log request and response bodies")
itemAddr = flag.String("item-addr", ":8082", "Item service address")
characterAddr = flag.String("character-addr", ":8083", "Character service address")
inventoryAddr = flag.String("inventory-addr", ":8081", "Inventory service address")
)
flag.Parse()
@ -49,12 +49,29 @@ func main() {
}
defer itemClientConnection.Close()
inventoryClientConnection, err := grpc.Dial(*inventoryAddr,
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("failed to connect to inventory service", err)
os.Exit(1)
}
defer inventoryClientConnection.Close()
characterClientConnection, err := grpc.Dial(*characterAddr,
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("failed to connect to character service", err)
os.Exit(1)
}
defer characterClientConnection.Close()
// Initialize the services.
var (
frontSvc front.Service
)
{
frontSvc = frontapi.NewFront(logger, itemClientConnection)
frontSvc = frontapi.NewFront(logger, itemClientConnection, characterClientConnection,
inventoryClientConnection)
}
// Wrap the services in endpoints that can be invoked from other services