Skip to content

Commit

Permalink
Merge pull request #45 from dgraph-io/srfrog/add_besteffort_req
Browse files Browse the repository at this point in the history
Add Best-Effort request flag
  • Loading branch information
srfrog authored Mar 1, 2019
2 parents d5a1729 + 0044a30 commit 0154083
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 125 deletions.
2 changes: 1 addition & 1 deletion example_set_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Person struct {
}

func Example_setObject() {
conn, err := grpc.Dial("127.0.0.1:9080", grpc.WithInsecure())
conn, err := grpc.Dial("127.0.0.1:9180", grpc.WithInsecure())
if err != nil {
log.Fatal("While trying to dial gRPC")
}
Expand Down
15 changes: 15 additions & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,21 @@ func ExampleTxn_Query_unmarshal() {
// Output: {"me":[{"name":"Alice","age":26,"raw_bytes":"cmF3X2J5dGVz","married":true,"friend":[{"name":"Bob","age":24}],"school":[{"name":"Crown Public School"}]}]}
}

func ExampleTxn_Query_besteffort() {
dg, cancel := getDgraphClient()
defer cancel()

// NOTE: Best effort only works with read-only queries.
txn := dg.NewReadOnlyTxn().BestEffort()
resp, err := txn.Query(context.Background(), `{ q(func: uid(0x1)) { uid } }`)
if err != nil {
log.Fatal(err)
}

fmt.Println(string(resp.Json))
// Output: {"q":[{"uid":"0x1"}]}
}

func ExampleTxn_Mutate_facets() {
dg, cancel := getDgraphClient()
defer cancel()
Expand Down
1 change: 1 addition & 0 deletions protos/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ message Request {
uint64 start_ts = 13;
LinRead lin_read = 14;
bool read_only = 15;
bool best_effort = 16;
}

message Response {
Expand Down
Loading

0 comments on commit 0154083

Please sign in to comment.