Commit 02edb1b
authored
Introduce transaction and query options (#753)
## Usage and product changes
**Introduce transaction options:**
* `transaction_timeout`: If set, specifies a timeout for killing
transactions automatically, preventing memory leaks in unclosed
transactions,
* `schema_lock_acquire_timeout`: If set, specifies how long the driver
should wait if opening a transaction is blocked by an exclusive schema
write lock.
Rust examples:
```rust
let options = TransactionOptions::new().transaction_timeout(Duration::from_secs(10));
let transaction =
driver.transaction_with_options(database.name(), TransactionType::Schema, options).await.unwrap();
```
Python example:
```py
options = TransactionOptions(transaction_timeout_millis=10_000)
tx = driver.transaction(database.name, TransactionType.SCHEMA, options)
```
Java example:
```java
TransactionOptions transactionOptions = new TransactionOptions().transactionTimeoutMillis(10_000);
Transaction transaction = driver.transaction(database.name(), Transaction.Type.SCHEMA, transactionOptions);
```
**Introduce query options:**
* `include_instance_types`: If set, specifies if types should be
included in instance structs returned in ConceptRow answers,
* `prefetch_size`: If set, specifies the number of extra query responses
sent before the client side has to re-request more responses. Increasing
this may increase performance for queries with a huge number of answers,
as it can reduce the number of network round-trips at the cost of more
resources on the server side.
Rust examples:
```rust
let options = QueryOptions::new().include_instance_types(true);
let answer = transaction.query_with_options("match $x isa person;", options).await.unwrap();
```
Python example:
```py
options = QueryOptions(include_instance_types=True)
answer = tx.query("match $x isa person;").resolve()
```
Java example:
```java
QueryOptions queryOptions = new QueryOptions().includeInstanceTypes(true);
QueryAnswer matchAnswer = transaction.query("match $x isa person;", queryOptions).resolve();
```
## Implementation
Add new structs and classes for `TransactionOptions` and `QueryOptions`
and extend `transaction` / `query` interfaces to accept optional
options.
Add relevant integration and behaviour tests. Update README and docs.1 parent a996fc1 commit 02edb1b
File tree
80 files changed
+1889
-1251
lines changed- c
- src
- swig
- dependencies/typedb
- docs/modules/ROOT/partials
- java
- connection
- transaction
- python
- connection
- transaction
- rust
- connection
- errors
- transaction
- java
- api
- connection
- test
- behaviour
- config
- connection
- transaction
- query
- integration
- python
- tests
- behaviour
- background
- cluster
- community
- connection/transaction
- query
- integration
- typedb
- api/connection
- connection
- rust
- src
- common
- connection
- network/proto
- database
- tests
- behaviour/steps
- connection
- integration
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
80 files changed
+1889
-1251
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
| 30 | + | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments