Skip to content

Commit

Permalink
update backend calls to match extra args proto spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpeterkort committed Nov 30, 2024
1 parent 89cf150 commit 878b740
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion gen3_writer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,14 @@ func (gh *Handler) MongoBulk(c *gin.Context) {
func (gh *Handler) BulkStreamRaw(c *gin.Context) {
writer, request, graph := getFields(c)
project_id := c.Param("project-id")
mapExtraArgs := map[string]any{}
proj_split := strings.Split(project_id, "-")
if len(proj_split) != 2 {
RegError(c, writer, graph, &middleware.ServerError{StatusCode: 400, Message: fmt.Sprintf("Error parsing project_id: %s. Must be of form PROGRAM-PROJECT", project_id)})
return
}
mapExtraArgs["auth_resource_path"] = "/programs/" + proj_split[0] + "/projects/" + proj_split[1]

host := "localhost:8202"
var err error
var res *gripql.BulkJsonEditResult
Expand All @@ -738,7 +746,7 @@ func (gh *Handler) BulkStreamRaw(c *gin.Context) {
conn, err := gripql.Connect(rpc.ConfigWithDefaults(host), true)
wait := make(chan bool)

VertChan, warnChan := streamJsonFromReader(reader, graph, project_id, 5)
VertChan, warnChan := streamJsonFromReader(reader, graph, mapExtraArgs, 5)

go func() {
for warning := range warnChan {
Expand Down
11 changes: 9 additions & 2 deletions gen3_writer/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func StreamVerticesFromReader(reader io.Reader, workers int) (chan *gripql.Verte
return vertChan, nil
}

func streamJsonFromReader(reader io.Reader, graph string, project_id string, workers int) (chan *gripql.RawJson, chan string) {
func streamJsonFromReader(reader io.Reader, graph string, mapExtraArgs map[string]any, workers int) (chan *gripql.RawJson, chan string) {
lineChan := processReader(reader, workers)

vertChan := make(chan *gripql.RawJson, workers)
Expand All @@ -162,15 +162,22 @@ func streamJsonFromReader(reader io.Reader, graph string, project_id string, wor
}
rawData := &gripql.RawJson{
Data: &structpb.Struct{},
ExtraArgs: &structpb.Struct{},
Graph: graph,
ProjectId: project_id,
}
err := jum.Unmarshal([]byte(line), rawData.Data)
if err != nil {
log.WithFields(log.Fields{"error": err}).Errorf("Unmarshaling into rawData.Data: %s", line)
warnings <- fmt.Sprintf("Error: %v when unmarshaling: %s", err, line)
continue
}
stuctpbExtraArgs, err := structpb.NewStruct(mapExtraArgs)
if err != nil {
log.WithFields(log.Fields{"error": err}).Errorf("Creating new StructPB rawData.ExtraArgs: %s", mapExtraArgs)
warnings <- fmt.Sprintf("Error: %v when creating new struct for extra args: %s", err, mapExtraArgs)
continue
}
rawData.ExtraArgs = stuctpbExtraArgs
vertChan <- rawData
}
}()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bmeg/grip-graphql
go 1.22.5

require (
github.com/bmeg/grip v0.0.0-20241122195322-515a682d56f7
github.com/bmeg/grip v0.0.0-20241130225536-67d787e0b831
github.com/dop251/goja v0.0.0-20240707163329-b1681fb2a2f5
github.com/gin-gonic/gin v1.8.1
github.com/golang-jwt/jwt/v5 v5.2.1
Expand All @@ -26,7 +26,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmeg/jsonpath v0.0.0-20210207014051-cca5355553ad // indirect
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92 // indirect
github.com/bmeg/jsonschemagraph v0.0.3-0.20241113190142-5e57a1561020 // indirect
github.com/bmeg/jsonschemagraph v0.0.3-0.20241130225037-5545ec0ffd4b // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/casbin/casbin/v2 v2.97.0 // indirect
github.com/casbin/govaluate v1.2.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ github.com/bmeg/grip v0.0.0-20241119230816-a7f6fdd48051 h1:r5AE3WgJqdxA7DJ2U7d2K
github.com/bmeg/grip v0.0.0-20241119230816-a7f6fdd48051/go.mod h1:fic/942cjKIBWnZ9HKzoknVhQHWOHYkbfCoTTQLT+2w=
github.com/bmeg/grip v0.0.0-20241122195322-515a682d56f7 h1:/y6m1fI9tZaaCy/DAgk+uZmQHdlaykx1G8rCJXQswiA=
github.com/bmeg/grip v0.0.0-20241122195322-515a682d56f7/go.mod h1:2YAjHdHHKDeUHtOui5g/xRFk6uosktkzLPFPY7n/4d8=
github.com/bmeg/grip v0.0.0-20241130225536-67d787e0b831 h1:P6iO3yzIYFsuG0Lfh7dj4WMuvLv/sXvV0QvUcBh+/LM=
github.com/bmeg/grip v0.0.0-20241130225536-67d787e0b831/go.mod h1:BlltO6pCUdfyqIc1RZFVqvSpH4Mzr47aCwI4Ex4JURQ=
github.com/bmeg/jsonpath v0.0.0-20210207014051-cca5355553ad h1:ICgBexeLB7iv/IQz4rsP+MimOXFZUwWSPojEypuOaQ8=
github.com/bmeg/jsonpath v0.0.0-20210207014051-cca5355553ad/go.mod h1:ft96Irkp72C7ZrUWRenG7LrF0NKMxXdRvsypo5Njhm4=
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92 h1:Myx/j+WxfEg+P3nDaizR1hBpjKSLgvr4ydzgp1/1pAU=
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92/go.mod h1:6v27bSBKXyIDFqlKQbUSnHlekE1y6bDkgWCuVEaDPng=
github.com/bmeg/jsonschemagraph v0.0.3-0.20241113190142-5e57a1561020 h1:7/dWlBDJdKYhtF31LO8zXcw/IcYsmp/MWpydk6PzuNA=
github.com/bmeg/jsonschemagraph v0.0.3-0.20241113190142-5e57a1561020/go.mod h1:k04v50661tQFKgYl6drQxWGf9q0dBmKhd6lwIk1rcCw=
github.com/bmeg/jsonschemagraph v0.0.3-0.20241130225037-5545ec0ffd4b h1:k9j0qId2gRBwYhSdvqlBfQQDNIU4nohG4J9lu9crWE0=
github.com/bmeg/jsonschemagraph v0.0.3-0.20241130225037-5545ec0ffd4b/go.mod h1:k04v50661tQFKgYl6drQxWGf9q0dBmKhd6lwIk1rcCw=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bufbuild/protovalidate-go v0.4.0 h1:ModSkCLEW07fiyGtdtMXKY+Gz3oPFKSfiaSCgL+FtpU=
Expand Down

0 comments on commit 878b740

Please sign in to comment.