Skip to content

Commit

Permalink
traverseMe added
Browse files Browse the repository at this point in the history
  • Loading branch information
autom8ter committed Dec 28, 2020
1 parent e1c8720 commit 674dac7
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.5
current_version = 0.0.6
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version := "0.0.5"
version := "0.0.6"

.DEFAULT_GOAL := help

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A command line utility for graphikDB
---
env-prefix: GRAPHIKCTL
config-path: ~/.graphikctl.yaml
default config-path: ~/.graphikctl.yaml
Usage:
graphikctl [command]
Expand All @@ -24,6 +24,7 @@ Available Commands:
edit graphikDB edit operations (doc, connection)
get graphikDB get operations (doc, connection, schema)
help Help about any command
put graphikDB put operations (doc, connection)
search graphikDB search operations (docs, connections)
stream graphikDB stream operations
traverse graphikDB traversal operations
Expand Down
36 changes: 36 additions & 0 deletions cmd/graph/traverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ func init() {
Traverse.Flags().IntVar(&limit, "limit", 0, "limit returned docs")
Traverse.Flags().BoolVar(&reverse, "reverse", false, "traversal algorithm to use (DFS/BFS)")

TraverseMe.Flags().StringVar(&docExpression, "doc-expression", "", "CEL expression used to determine which documents to return")
TraverseMe.Flags().StringVar(&connectionExpression, "connection-expression", "", "CEL expression used to determine which connections to traverse")
TraverseMe.Flags().StringVar(&sort, "sort", "", "sort documents on this attribute")
TraverseMe.Flags().StringVar(&algorithm, "algorithm", apipb.Algorithm_DFS.String(), "traversal algorithm to use (DFS/BFS)")
TraverseMe.Flags().IntVar(&limit, "limit", 0, "limit returned docs")
TraverseMe.Flags().BoolVar(&reverse, "reverse", false, "traversal algorithm to use (DFS/BFS)")

}

var Traverse = &cobra.Command{
Expand Down Expand Up @@ -54,3 +61,32 @@ var Traverse = &cobra.Command{
fmt.Println(protojson.Format(resp))
},
}

var TraverseMe = &cobra.Command{
Use: "traverseMe",
Short: "graphikDB traversal(me) operations",
Run: func(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
client, err := helpers.GetClient(ctx)
if err != nil {
fmt.Println(err.Error())
return
}
resp, err := client.TraverseMe(ctx, &apipb.TraverseMeFilter{
DocExpression: docExpression,
ConnectionExpression: connectionExpression,
Limit: uint64(limit),
Sort: sort,
Reverse: reverse,
Algorithm: apipb.Algorithm(apipb.Algorithm_value[algorithm]),
MaxDepth: uint64(maxDepth),
MaxHops: uint64(maxHops),
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(protojson.Format(resp))
},
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func init() {
graph.Traverse,
graph.Edit,
graph.Put,
graph.TraverseMe,
)
}

Expand Down
1 change: 1 addition & 0 deletions docs/graphikctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ default config-path: ~/.graphikctl.yaml
* [graphikctl search](graphikctl_search.md) - graphikDB search operations (docs, connections)
* [graphikctl stream](graphikctl_stream.md) - graphikDB stream operations
* [graphikctl traverse](graphikctl_traverse.md) - graphikDB traversal operations
* [graphikctl traverseMe](graphikctl_traverseMe.md) - graphikDB traversal(me) operations

###### Auto generated by spf13/cobra on 28-Dec-2020
31 changes: 31 additions & 0 deletions docs/graphikctl_traverseMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## graphikctl traverseMe

graphikDB traversal(me) operations

```
graphikctl traverseMe [flags]
```

### Options

```
--algorithm string traversal algorithm to use (DFS/BFS) (default "DFS")
--connection-expression string CEL expression used to determine which connections to traverse
--doc-expression string CEL expression used to determine which documents to return
-h, --help help for traverseMe
--limit int limit returned docs
--reverse traversal algorithm to use (DFS/BFS)
--sort string sort documents on this attribute
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.graphikctl.yaml)
```

### SEE ALSO

* [graphikctl](graphikctl.md) -

###### Auto generated by spf13/cobra on 28-Dec-2020
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module github.com/graphikDB/graphikctl
go 1.15

require (
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.2
github.com/graphikDB/graphik v0.12.1
github.com/graphikDB/graphik v0.13.1
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect
Expand All @@ -13,4 +14,5 @@ require (
github.com/spf13/viper v1.7.1
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
google.golang.org/protobuf v1.25.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ github.com/graphikDB/generic v0.0.1/go.mod h1:3Dji4QoogUaekuR3a+qDFRAmut1CUtsMkh
github.com/graphikDB/graphik v0.8.2/go.mod h1:fJHmHpdS8Qs2Aj9WVAzTVHHSh03o26208HH4UAuFCMY=
github.com/graphikDB/graphik v0.12.1 h1:J4SuA1ycqSdyB+pQ3CScL2D04VgUsagnbweZmQEEMdc=
github.com/graphikDB/graphik v0.12.1/go.mod h1:PkgMXjsc1NozbbX9SOlWHwuh13g0GVAg1Ld094aRyzU=
github.com/graphikDB/graphik v0.13.1 h1:HoKADMvrep/XnuobsYfMGD6nh5yliZeeQRtR/qCImwo=
github.com/graphikDB/graphik v0.13.1/go.mod h1:PkgMXjsc1NozbbX9SOlWHwuh13g0GVAg1Ld094aRyzU=
github.com/graphikDB/raft v0.0.0/go.mod h1:WIylhU9T0j6k0Ynh8RMb2PCvUYehlgCrTCTCusMLO6g=
github.com/graphikDB/trigger v0.0.13/go.mod h1:RZn4pNk7i0xbur4PBtRR8L1IJedr1ll/mymrwY2M4dQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

const Version = "0.0.5"
const Version = "0.0.6"

0 comments on commit 674dac7

Please sign in to comment.