Skip to content
Snippets Groups Projects
Commit 3b4ea724 authored by Leonardo Christino's avatar Leonardo Christino
Browse files

Schema request pathway fix to support frontend calls

Save database port to user's databases
Parse database type with optional
Change makefiles for fast rollout for local k8s instance and to properly tag to the correct dockerhub namespace
Enable WSL deployment of backend, which includes some new parameters to the deployment script
Fixes to wrong cors header configuration when calling backend from the frontend (not testing)
Small fixes to k8s service naming for consistency
Addition of some trace logs for debugging the schema call pathway
parent e2971df3
No related branches found
No related tags found
No related merge requests found
Pipeline #122669 failed
......@@ -8,6 +8,7 @@ package rpcdriver
import (
"context"
"errors"
"log"
"schema-orchestrator/internal/drivers/rpcdriver/databaseTypeService"
"google.golang.org/grpc"
......@@ -15,6 +16,7 @@ import (
/*
GetDatabaseType opens a gRPC connection to the user management service and retrieves the database info for the given client and database name
clientID: *string, the ID of the client
databaseName: *string, the name of the database
Return: (*string, error), returns the type of the database and a potential error
......@@ -22,18 +24,24 @@ GetDatabaseType opens a gRPC connection to the user management service and retri
func (driver *Driver) GetDatabaseType(clientID *string, databaseName *string) (*string, error) {
conn, err := grpc.Dial("user-management-service:9000", grpc.WithInsecure())
if err != nil {
log.Println("ERROR connecting to user-management-service:9000")
log.Printf("ERROR %v", err)
return nil, err
}
defer conn.Close()
grpcClient := databaseTypeService.NewDatabaseTypeServiceClient(conn)
response, err := grpcClient.GetDatabaseType(context.Background(), &databaseTypeService.DatabaseTypeRequest{ClientID: *clientID, DatabaseName: *databaseName})
if err != nil {
log.Println("ERROR querying to user-management-service:9000")
log.Printf("ERROR %v", err)
return nil, err
}
defer conn.Close()
var databaseType string
log.Printf("Responding with database type: %d", response.DatabaseType) // TODO: remove
switch response.DatabaseType {
case databaseTypeService.DatabaseTypeResponse_ARANGODB:
databaseType = "arangodb"
......
......@@ -10,17 +10,20 @@ ProduceSchemaRetrievalRequest publishes a schema retrieval request
databaseName: string, the name of the database
*/
func (s *Service) ProduceSchemaRetrievalRequest(request []byte, sessionID string, clientID string, databaseName string) {
headers := make(map[string]interface{})
headers["sessionID"] = sessionID
headers["clientID"] = clientID
// Send the message to the correct queue
// Request the database type from the user management service
databaseType, err := s.rpcDriver.GetDatabaseType(&clientID, &databaseName)
if err != nil {
return
log.Println("Error producing schema retrieval! No database type found")
// log.Println("No valid database type found, defaulting to neo4j") // TODO
// s.requestProducer.PublishMessage(&request, "neo4j-schema-request", &headers)
return // TODO
}
headers := make(map[string]interface{})
headers["sessionID"] = sessionID
headers["clientID"] = clientID
switch *databaseType {
case "arangodb":
log.Println("Publishing to arangodb queue")
......
......@@ -12,6 +12,7 @@ import (
/*
Retrieve retrieves the schema. It will check if the schema is currently being made, if not it will check if it has been cached, if not it will produce a request to create it.
request: *[]byte, the raw JSON request (contains cached boolean and database name)
sessionID: string, the session ID
clientID: string, the client ID
......@@ -44,6 +45,8 @@ func (s *Service) Retrieve(request *[]byte, sessionID string, clientID string, d
// Check if the schema should be force refreshed
if !cached {
log.Println("Not cached! Producing a schema retrieval request")
// Produce a schema retrieval request
s.producer.ProduceSchemaRetrievalRequest(*request, sessionID, clientID, databaseName)
return nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment