-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rewrite #3
rewrite #3
Changes from 22 commits
656d6c2
08b9f57
e0cfc1f
45e530e
1b4c7e3
92a8f1b
674be75
922dcfe
59f3af2
fe30683
5e7a972
c486250
7c9151e
fe3e283
a4baedd
c49e266
1a1b53e
61cca30
8973bcc
7eed759
032ddfa
5c3e9fe
a167a8d
d5c0c08
e3842d7
02c3b22
7113007
b9ef5eb
86da116
e9d6774
fb4c479
dbc2bbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will build a golang project | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: Go | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
services: | ||
falkordb: | ||
image: falkordb/falkordb:edge | ||
ports: | ||
- 6379:6379 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,26 +1,24 @@ | ||||||
[![license](https://img.shields.io/github/license/RedisGraph/redisgraph-go.svg)](https://github.com/RedisGraph/redisgraph-go) | ||||||
[![CircleCI](https://circleci.com/gh/RedisGraph/redisgraph-go/tree/master.svg?style=svg)](https://circleci.com/gh/RedisGraph/redisgraph-go/tree/master) | ||||||
[![GitHub issues](https://img.shields.io/github/release/RedisGraph/redisgraph-go.svg)](https://github.com/RedisGraph/redisgraph-go/releases/latest) | ||||||
[![Codecov](https://codecov.io/gh/RedisGraph/redisgraph-go/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisGraph/redisgraph-go) | ||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/RedisGraph/redisgraph-go)](https://goreportcard.com/report/github.com/RedisGraph/redisgraph-go) | ||||||
[![GoDoc](https://godoc.org/github.com/RedisGraph/redisgraph-go?status.svg)](https://godoc.org/github.com/RedisGraph/redisgraph-go) | ||||||
[![license](https://img.shields.io/github/license/FalkorDB/falkordb-go.svg)](https://github.com/FalkorDB/falkordb-go) | ||||||
[![GitHub issues](https://img.shields.io/github/release/FalkorDB/falkordb-go.svg)](https://github.com/FalkorDB/falkordb-go/releases/latest) | ||||||
[![Codecov](https://codecov.io/gh/FalkorDB/falkordb-go/branch/master/graph/badge.svg)](https://codecov.io/gh/FalkorDB/falkordb-go) | ||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/FalkorDB/falkordb-go)](https://goreportcard.com/report/github.com/FalkorDB/falkordb-go) | ||||||
[![GoDoc](https://godoc.org/github.com/FalkorDB/falkordb-go?status.svg)](https://godoc.org/github.com/FalkorDB/falkordb-go) | ||||||
|
||||||
# redisgraph-go | ||||||
[![Forum](https://img.shields.io/badge/Forum-RedisGraph-blue)](https://forum.redislabs.com/c/modules/redisgraph) | ||||||
[![Discord](https://img.shields.io/discord/697882427875393627?style=flat-square)](https://discord.gg/gWBRT6P) | ||||||
# falkordb-go | ||||||
[![Discord](https://img.shields.io/discord/1146782921294884966?style=flat-square)](https://discord.gg/6M4QwDXn2w) | ||||||
|
||||||
`redisgraph-go` is a Golang client for the [RedisGraph](https://oss.redislabs.com/redisgraph/) module. It relies on [`redigo`](https://github.com/gomodule/redigo) for Redis connection management and provides support for RedisGraph's QUERY, EXPLAIN, and DELETE commands. | ||||||
`falkordb-go` is a Golang client for the [FalkorDB](https://falkordb.com) database. | ||||||
|
||||||
## Installation | ||||||
|
||||||
Simply do: | ||||||
```sh | ||||||
$ go get github.com/redislabs/redisgraph-go | ||||||
$ go get github.com/FalkorDB/falkordb-go | ||||||
``` | ||||||
|
||||||
## Usage | ||||||
|
||||||
The complete `redisgraph-go` API is documented on [GoDoc](https://godoc.org/github.com/RedisGraph/redisgraph-go). | ||||||
The complete `falkordb-go` API is documented on [GoDoc](https://godoc.org/github.com/FalkorDB/falkordb-go). | ||||||
|
||||||
```go | ||||||
package main | ||||||
|
@@ -29,51 +27,23 @@ import ( | |||||
"fmt" | ||||||
"os" | ||||||
|
||||||
"github.com/gomodule/redigo/redis" | ||||||
rg "github.com/redislabs/redisgraph-go" | ||||||
"github.com/FalkorDB/falkordb-go" | ||||||
) | ||||||
|
||||||
func main() { | ||||||
conn, _ := redis.Dial("tcp", "127.0.0.1:6379") | ||||||
defer conn.Close() | ||||||
db, _ := falkordb.FalkorDBNew(&falkordb.ConnectionOption{Addr: "0.0.0.0:6379"}) | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for db, err := falkordb.FalkorDBNew(&falkordb.ConnectionOption{Addr: "0.0.0.0:6379"})
if err != nil {
log.Fatalf("Failed to create FalkorDB connection: %v", err)
} |
||||||
graph := rg.GraphNew("social", conn) | ||||||
graph := db.SelectGraph("social") | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for graph, err := db.SelectGraph("social")
if err != nil {
log.Fatalf("Failed to select graph: %v", err)
} |
||||||
graph.Delete() | ||||||
graph.Query("CREATE (:Person {name: 'John Doe', age: 33, gender: 'male', status: 'single'})-[:VISITED]->(:VISITED {name: 'Japan'})") | ||||||
|
||||||
john := rg.Node{ | ||||||
Label: "person", | ||||||
Properties: map[string]interface{}{ | ||||||
"name": "John Doe", | ||||||
"age": 33, | ||||||
"gender": "male", | ||||||
"status": "single", | ||||||
}, | ||||||
} | ||||||
graph.AddNode(&john) | ||||||
|
||||||
japan := rg.Node{ | ||||||
Label: "country", | ||||||
Properties: map[string]interface{}{ | ||||||
"name": "Japan", | ||||||
}, | ||||||
} | ||||||
graph.AddNode(&japan) | ||||||
|
||||||
edge := rg.Edge{ | ||||||
Source: &john, | ||||||
Relation: "visited", | ||||||
Destination: &japan, | ||||||
query, err := "MATCH (p:Person)-[v:VISITED]->(c:VISITED) RETURN p.name, p.age, c.name" | ||||||
if err != nil { | ||||||
os.Exit(1) | ||||||
} | ||||||
graph.AddEdge(&edge) | ||||||
|
||||||
graph.Commit() | ||||||
|
||||||
query := `MATCH (p:person)-[v:visited]->(c:country) | ||||||
RETURN p.name, p.age, c.name` | ||||||
|
||||||
// result is a QueryResult struct containing the query's generated records and statistics. | ||||||
result, _ := graph.Query(query) | ||||||
result, _ := graph.Query(query, nil, nil) | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement error handling for the result, err := graph.Query(query, nil, nil)
if err != nil {
log.Fatalf("Query failed: %v", err)
} |
||||||
// Pretty-print the full result set as a table. | ||||||
result.PrettyPrint() | ||||||
|
@@ -93,7 +63,7 @@ func main() { | |||||
|
||||||
// Path matching example. | ||||||
query = "MATCH p = (:person)-[:visited]->(:country) RETURN p" | ||||||
result, err := graph.Query(query) | ||||||
result, err := graph.Query(query, nil, nil) | ||||||
if err != nil { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the type assertion syntax to match the expected type from the - p, ok := r.GetByIndex(0).(rg.Path)
+ p, ok := r.GetByIndex(0).(falkordb.Path) Ensure the type Committable suggestion
Suggested change
|
||||||
fmt.Println(err) | ||||||
os.Exit(1) | ||||||
|
@@ -125,15 +95,13 @@ Age: 33 | |||||
|
||||||
## Running queries with timeouts | ||||||
|
||||||
Queries can be run with a millisecond-level timeout as described in [the module documentation](https://oss.redis.com/redisgraph/configuration/#timeout). To take advantage of this feature, the `QueryOptions` struct should be used: | ||||||
Queries can be run with a millisecond-level timeout as described in [the documentation](https://docs.falkordb.com/configuration.html#timeout). To take advantage of this feature, the `QueryOptions` struct should be used: | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling to the example code to promote best practices. options := NewQueryOptions().SetTimeout(10) // 10-millisecond timeout
res, err := graph.QueryWithOptions("MATCH (src {name: 'John Doe'})-[*]->(dest) RETURN dest", options)
if err != nil {
log.Fatalf("Query failed: %v", err)
} Including error handling in examples encourages developers to write more robust and error-resistant code. Would you like me to help with updating the documentation to include error handling in all relevant examples? |
||||||
```go | ||||||
options := NewQueryOptions().SetTimeout(10) // 10-millisecond timeout | ||||||
res, err := graph.QueryWithOptions("MATCH (src {name: 'John Doe'})-[*]->(dest) RETURN dest", options) | ||||||
res, err := graph.Query("MATCH (src {name: 'John Doe'})-[*]->(dest) RETURN dest", nil, options) | ||||||
``` | ||||||
Comment on lines
+98
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling to the example code to promote best practices. options := NewQueryOptions().SetTimeout(10) // 10-millisecond timeout
res, err := graph.Query("MATCH (src {name: 'John Doe'})-[*]->(dest) RETURN dest", nil, options)
if err != nil {
log.Fatalf("Query failed: %v", err)
} Including error handling in examples encourages developers to write more robust and error-resistant code. |
||||||
|
||||||
`ParameterizedQueryWithOptions` and `ROQueryWithOptions` endpoints are also exposed by the client. | ||||||
|
||||||
## Running tests | ||||||
|
||||||
A simple test suite is provided, and can be run with: | ||||||
|
@@ -142,8 +110,8 @@ A simple test suite is provided, and can be run with: | |||||
$ go test | ||||||
``` | ||||||
|
||||||
The tests expect a Redis server with the RedisGraph module loaded to be available at localhost:6379 | ||||||
The tests expect a FalkorDB server to be available at localhost:6379 | ||||||
|
||||||
## License | ||||||
|
||||||
redisgraph-go is distributed under the BSD3 license - see [LICENSE](LICENSE) | ||||||
falkordb-go is distributed under the BSD3 license - see [LICENSE](LICENSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start the sentence with an uppercase letter to maintain consistency and professionalism in documentation.
Committable suggestion