-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add timeout parameters to transaction requests. (#172)
Problem: Currently, the only way to set timeouts for a request is to either: 1. Set a timeout at the stub level with stub.withDeadlineAfter (i.e., create a new stub and DgraphClient) 2. Set a timeout for every request of the stub using a ClientInterceptor. The downside for (1) is the need to create a new stub and client in order to set a timeout. The downside for (2) is the inability to set a timeout only for a certain request (i.e, some requests should timeout after 500 milliseconds and others 10 seconds). Solution: (1) and (2) can be resolved for use cases where the timeout is set only for a single request in a transaction by passing in a specified timeout when sending the request. This change overloads the query, mutate, and doRequest methods to allow setting the timeout duration and unit. They're set like stub.withDeadlineAfter but on the request itself. Including the existing methods, here are the overloaded methods with the timeout parameters: * AsyncTransaction * queryWithVars(final string query, final Map<string, String> vars); * queryWithVars(final string query, final Map<string, String> vars, long duration, TimeUnit units); * query(final string query); * query(final string query, long duration, TimeUnit units); * queryRDFWithVars(final string query, final Map<String, String> vars); * queryRDFWithVars(final string query, final Map<String, String> vars, long duration, TimeUnit units); * queryRDF(final string query, final Map<String, String> vars); * queryRDF(final string query, final Map<String, String> vars, long duration, TimeUnit units); * mutate(Mutation mutation); * mutate(Mutation mutation, long duration, TimeUnit units); * doRequest(Request request); * doRequest(Request request, long duration, TimeUnit units); * Transaction * queryWithVars(final string query, final Map<string, String> vars); * queryWithVars(final string query, final Map<string, String> vars, long duration, TimeUnit units); * query(final string query); * query(final string query, long duration, TimeUnit units); * queryRDFWithVars(final string query, final Map<String, String> vars); * queryRDFWithVars(final string query, final Map<String, String> vars, long duration, TimeUnit units); * queryRDF(final string query, final Map<String, String> vars); * queryRDF(final string query, final Map<String, String> vars, long duration, TimeUnit units); * mutate(Mutation mutation); * mutate(Mutation mutation, long duration, TimeUnit units); * doRequest(Request request); * doRequest(Request request, long duration, TimeUnit units); Misc: * tests: Add docker-compose.test.yml and docker-test-secret.yml * chore: Fix javadoc typos.
- Loading branch information
Showing
11 changed files
with
385 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Auto-generated with: [./compose -a 3 -z 1 --acl --port_offset=100] | ||
# | ||
version: "3.5" | ||
services: | ||
alpha1: | ||
image: dgraph/dgraph:v21.12.0 | ||
container_name: alpha1 | ||
working_dir: /data/alpha1 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 8180:8180 | ||
- 9180:9180 | ||
volumes: | ||
- type: bind | ||
source: ./docker-test-secret.txt | ||
target: /secret/hmac | ||
read_only: true | ||
command: dgraph alpha -o 100 --my=alpha1:7180 --zero=zero1:5180 --logtostderr | ||
-v=2 --raft "idx=1; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;" | ||
--acl "secret-file=/secret/hmac; access-ttl=3s" | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 32G | ||
alpha2: | ||
image: dgraph/dgraph:v21.12.0 | ||
container_name: alpha2 | ||
working_dir: /data/alpha2 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 8182:8182 | ||
- 9182:9182 | ||
volumes: | ||
- type: bind | ||
source: ./docker-test-secret.txt | ||
target: /secret/hmac | ||
read_only: true | ||
command: dgraph alpha -o 102 --my=alpha2:7182 --zero=zero1:5180 --logtostderr | ||
-v=2 --raft "idx=2; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;" | ||
--acl "secret-file=/secret/hmac; access-ttl=3s" | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 32G | ||
alpha3: | ||
image: dgraph/dgraph:v21.12.0 | ||
container_name: alpha3 | ||
working_dir: /data/alpha3 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 8183:8183 | ||
- 9183:9183 | ||
volumes: | ||
- type: bind | ||
source: ./docker-test-secret.txt | ||
target: /secret/hmac | ||
read_only: true | ||
command: dgraph alpha -o 103 --my=alpha3:7183 --zero=zero1:5180 --logtostderr | ||
-v=2 --raft "idx=3; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;" | ||
--acl "secret-file=/secret/hmac; access-ttl=3s" | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 32G | ||
zero1: | ||
image: dgraph/dgraph:v21.12.0 | ||
container_name: zero1 | ||
working_dir: /data/zero1 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 5180:5180 | ||
- 6180:6180 | ||
command: dgraph zero -o 100 --raft='idx=1' --my=zero1:5180 --replicas=3 | ||
--logtostderr -v=2 --bindall | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 32G | ||
volumes: {} |
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 @@ | ||
12345678901234567890123456789012 |
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.