-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add neo4j eval, default port and host * simplified evalNeo4j, add test case for getConnectionString * make map * Added new neo4j field to selection * go-json as an internal package and initialize map outside loop * Neo4j CI test * docker fix
- Loading branch information
Showing
11 changed files
with
229 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package runner | ||
|
||
import ( | ||
"io" | ||
|
||
jsonutil "github.com/multiprocessio/go-json" | ||
"github.com/neo4j/neo4j-go-driver/v4/neo4j" | ||
) | ||
|
||
func (ec EvalContext) evalNeo4j(panel *PanelInfo, dbInfo DatabaseConnectorInfoDatabase, server *ServerInfo, w io.Writer) error { | ||
_, conn, err := ec.getConnectionString(dbInfo) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
password, err := ec.decrypt(&dbInfo.Password) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
driver, err := neo4j.NewDriver(conn, neo4j.BasicAuth(dbInfo.Username, password, "")) | ||
if err != nil { | ||
return err | ||
} | ||
defer driver.Close() | ||
|
||
sess := driver.NewSession(neo4j.SessionConfig{}) | ||
|
||
result, err := sess.Run(panel.Content, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return withJSONArrayOutWriterFile(w, func(w *jsonutil.StreamEncoder) error { | ||
records, err := result.Collect() | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
row := map[string]any{} | ||
for _, record := range records { | ||
for _, key := range record.Keys { | ||
value, ok := record.Get(key) | ||
if ok { | ||
row[key] = value | ||
} else { | ||
row[key] = nil | ||
} | ||
} | ||
|
||
if err := w.EncodeRow(row); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return result.Err() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.