Skip to content

Commit f0ddbec

Browse files
authored
Update transaction and query options specifications for GRPC and HTTP (#931)
## Goal Add transaction and query options specification for GRPC and HTTP. ## Implementation Update HTTP's answerCountLimit behavior for write queries to match the updated behavior in typedb/typedb#7437. Add a new section in the server transactions manual describing transaction and query options. Save descriptions and default values of the options in a separate `resources` folder to: * include them in asciidoc tables in the server transactions manual; * include them in asciidoc tables in the HTTP endpoint api reference; * copy them into the codegen comments in drivers.
1 parent fda087e commit f0ddbec

File tree

6 files changed

+192
-51
lines changed

6 files changed

+192
-51
lines changed

drivers/modules/ROOT/pages/http/api-reference.adoc

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,18 @@ Open a new transaction and receive a unique transaction id.
748748
[cols="h,3a"]
749749
|===
750750
| Field | Description
751-
| `schemaLockAcquireTimeoutMillis` | Timeout for a schema transaction to acquire the exclusive schema lock of the database. Can be used to wait until a previous schema transaction finishes and releases the exclusivity lock. Specified in milliseconds. **Default:** 10 seconds.
752-
| `transactionTimeoutMillis` | The maximum amount of time a transaction can stay opened. It will be closed automatically without preserving its changes and finishing its active queries after this timeout. Specified in milliseconds. **Default:** 5 minutes.
751+
| `transactionTimeoutMillis` |
752+
include::{page-version}@manual:resources:partial$options-descriptions/transaction.adoc[tag=transaction-timeout]
753+
754+
Specified in milliseconds. **Default:**
755+
include::{page-version}@manual:resources:partial$options-descriptions/transaction.adoc[tag=transaction-timeout-default]
756+
757+
758+
| `schemaLockAcquireTimeoutMillis` |
759+
include::{page-version}@manual:resources:partial$options-descriptions/transaction.adoc[tag=schema-lock-acquire-timeout]
760+
761+
Specified in milliseconds. **Default:**
762+
include::{page-version}@manual:resources:partial$options-descriptions/transaction.adoc[tag=schema-lock-acquire-timeout-default]
753763
|===
754764
// end::transaction-options[]
755765

@@ -1043,19 +1053,19 @@ This endpoint allows running multiple sequential queries before committing.
10431053
[cols="h,3a"]
10441054
|===
10451055
| Field | Description
1046-
| `includeInstanceTypes` | An optimization flag: whether to include the types of the returned instance concepts in concept row responses or not. **Default:** true.
1047-
| `answerCountLimit` | The maximum allowed size of concept rows or concept documents answers returned. Used to limit the network load. **Default:** 10 000.
1056+
| `includeInstanceTypes` |
1057+
include::{page-version}@manual:resources:partial$options-descriptions/query.adoc[tag=include-instance-types]
10481058

1049-
If used in a read query, at most `answerCountLimit` answers will be returned. If there are more answers cut, a relevant `warning` will be provided in the response.
1059+
**Default:**
1060+
include::{page-version}@manual:resources:partial$options-descriptions/query.adoc[tag=include-instance-types-default]
10501061

1051-
If used in a write query and is hit, the operation will fail completely.
10521062

1053-
[NOTE]
1054-
====
1055-
This behaviour will be changed in the next stable version of TypeDB:
1063+
| `answerCountLimit` |
1064+
include::{page-version}@manual:resources:partial$options-descriptions/query.adoc[tag=answer-count-limit]
1065+
If there are more answers cut, a relevant `warning` will be provided in the response.
10561066

1057-
If used in a write query, at most `answerCountLimit` answers will be returned. All changes, including both returned and not returned, will be applied.
1058-
====
1067+
**Default:**
1068+
include::{page-version}@manual:resources:partial$options-descriptions/query.adoc[tag=answer-count-limit-default]
10591069

10601070
|===
10611071
// end::query-options[]

drivers/modules/ROOT/pages/http/index.adoc

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ The TypeDB HTTP endpoint can be used to perform database management, user manage
44

55
== Server configuration
66

7-
TypeDB server by runs both a gRPC (standard for most of the client applications) and an HTTP endpoint by default. Both endpoints have common authentication and xref:{page-version}@manual::configure/encryption.adoc[encryption settings]. Additionally, it is possible to disable the HTTP endpoint and change its default port.
7+
TypeDB server by runs both a gRPC (standard for most of the client applications) and an HTTP endpoint by default.
8+
Both endpoints have common authentication and xref:{page-version}@manual::configure/encryption.adoc[encryption settings].
9+
Additionally, it is possible to disable the HTTP endpoint and change its default port.
810

911
[NOTE]
1012
====
@@ -18,13 +20,16 @@ Please visit xref:{page-version}@manual::configure/server.adoc#_command_line_arg
1820
[#_authentication]
1921
=== Authentication
2022

21-
Mostly all methods require Token-based authorization. These temporary tokens can be generated through a xref:{page-version}@drivers::http/api-reference.adoc#_sign_in[`POST` request to `localhost:8000/v1/signin`]. Provide your TypeDB user credentials in the request's body.
23+
Mostly all methods require Token-based authorization.
24+
These temporary tokens can be generated through a xref:{page-version}@drivers::http/api-reference.adoc#_sign_in[`POST` request to `localhost:8000/v1/signin`].
25+
Provide your TypeDB user credentials in the request's body.
2226

2327
Change the xref:{page-version}@manual::configure/server.adoc#_command_line_arguments[`server.authentication.token_ttl_seconds`] parameter in the server's configuration to modify the time the tokens will remain valid before a new sign in request is required.
2428

2529
=== Encryption
2630

27-
If xref:{page-version}@manual::configure/encryption.adoc[server encryption] is set up, its settings are also applied to the HTTP endpoint, and the endpoint access will be additionally protected. Visit the xref:{page-version}@manual::configure/server.adoc#_encryption[server configuration] page for more details.
31+
If xref:{page-version}@manual::configure/encryption.adoc[server encryption] is set up, its settings are also applied to the HTTP endpoint, and the endpoint access will be additionally protected.
32+
Visit the xref:{page-version}@manual::configure/server.adoc#_encryption[server configuration] page for more details.
2833

2934
=== CORS
3035

@@ -39,14 +44,18 @@ See xref:{page-version}@drivers::http/api-reference.adoc[] to access available d
3944

4045
=== Understanding query answers
4146

42-
The TypeDB HTTP endpoint supports all types of xref:{page-version}@manual::queries/transactions.adoc[transactions] and xref:{page-version}@manual::queries/index.adoc[queries]. The common xref:{page-version}@manual::queries/answers.adoc[query answer type], a list of concept rows, is represented in the HTTP endpoint like the following document:
47+
The TypeDB HTTP endpoint supports all types of xref:{page-version}@manual::queries/transactions.adoc[transactions] and xref:{page-version}@manual::queries/index.adoc[queries].
48+
The common xref:{page-version}@manual::queries/answers.adoc[query answer type], a list of concept rows, is represented in the HTTP endpoint like the following document:
4349

4450
.Concept rows answer
4551
[%collapsible]
4652
====
4753
Each successful query response contains a query type, an answer type, an optional warning message, and the list of answers containing concepts (if applicable).
4854
49-
The `answers` field contains a list of documents with variables as keys and concepts as values. Each concept contains a `kind` field for unambiguous parsing. Each type has a label, and each instance has an optional description of its type, if the specific query option (`includeInstanceTypes`) is enabled. See all the possible concept variants below.
55+
The `answers` field contains a list of documents with variables as keys and concepts as values.
56+
Each concept contains a `kind` field for unambiguous parsing.
57+
Each type has a label, and each instance has an optional description of its type, if the specific query option (`includeInstanceTypes`) is enabled.
58+
See all the possible concept variants below.
5059
5160
include::{page-version}@drivers:resources:partial$http-api/responses/query-concept-rows-example.json.adoc[]
5261
====
@@ -57,7 +66,8 @@ The result above can be achieved in two different ways.
5766

5867
This will except you to manually open, close, and commit transactions used for querying.
5968

60-
Open a transaction using a `POST` request `/v1/transactions/open`. Provide an authorization token in the header (see xref:{page-version}@drivers::http/index.adoc#_authentication[authentication] above) and a JSON body, containing information about the target database and required transaction type:
69+
Open a transaction using a `POST` request `/v1/transactions/open`.
70+
Provide an authorization token in the header (see xref:{page-version}@drivers::http/index.adoc#_authentication[authentication] above) and a JSON body, containing information about the target database and required transaction type:
6171

6272
[source,json]
6373
----
@@ -69,7 +79,9 @@ Open a transaction using a `POST` request `/v1/transactions/open`. Provide an au
6979

7080
[NOTE]
7181
====
72-
Schema transactions have an exclusive lock on the database and prevent other transactions from opening. If you don't close a schema transaction and lose its ID, it will be closed automatically based on the transaction timeout specified in the request (this parameter can be added to the request above):
82+
Schema transactions have an exclusive lock on the database and prevent other transactions from opening.
83+
If you don't close a schema transaction and lose its ID, it will be closed automatically based on the transaction timeout specified in the request (this parameter can be added to the request above):
84+
7385
[source,json]
7486
----
7587
"transactionOptions": {
@@ -79,6 +91,7 @@ Schema transactions have an exclusive lock on the database and prevent other tra
7991
====
8092

8193
If everything is correct, you will receive a response containing a body like:
94+
8295
[source,json]
8396
----
8497
{
@@ -87,6 +100,7 @@ If everything is correct, you will receive a response containing a body like:
87100
----
88101

89102
Then, send a `POST` query request to `v1/transactions/e1f8583c-2a03-4aac-a260-ec186369e86f/query` with the same authorization token in the header and the following JSON body included:
103+
90104
[source,json]
91105
----
92106
{
@@ -101,9 +115,12 @@ Don't forget to close the transaction when the work is done.
101115

102116
=== One-shot query
103117

104-
To avoid manual transaction management, a one-shot query endpoint can be used. It opens and automatically closes or commits a transaction for each query sent.
118+
To avoid manual transaction management, a one-shot query endpoint can be used.
119+
It opens and automatically closes or commits a transaction for each query sent.
120+
121+
Send a single `POST` request to `/v1/query`.
122+
Provide an authorization token in the header (see xref:{page-version}@drivers::http/index.adoc#_authentication[authentication] above) and the following body containing information about the target database, transaction type required, query, and optional options:
105123

106-
Send a single `POST` request to `/v1/query`. Provide an authorization token in the header (see xref:{page-version}@drivers::http/index.adoc#_authentication[authentication] above) and the following body containing information about the target database, transaction type required, query, and optional options:
107124
[source,json]
108125
----
109126
{
@@ -121,21 +138,18 @@ With this, you don't need to worry about forgotten transactions.
121138

122139
=== Running big queries
123140

124-
The current version of the HTTP endpoint does not support query answer streaming. Unlike in gRPC, the query results will be fully consumed before an initial answer is received on the client side, and the whole list of concept rows or documents will be returned in a single response.
141+
The current version of the HTTP endpoint does not support query answer streaming.
142+
Unlike in gRPC, the query results will be fully consumed before an initial answer is received on the client side, and the whole list of concept rows or documents will be returned in a single response.
125143

126-
While this mechanism will be enhanced in the future, for safety purposes, please use a special query option `answerCountLimit` to limit the amount of produced results and avoid too long query execution. The default value of ten thousand answers can be extended if you are ready for the consequences.
144+
While this mechanism will be enhanced in the future, for safety purposes, please use a special query option `answerCountLimit` to limit the amount of produced results and avoid too long query execution.
145+
The default value of ten thousand answers can be extended if you are ready for the consequences.
127146

128147
If this limit is hit:
129148

130-
- Read queries will return `206 Partial Content` with all the answers
131-
processed;
132-
- Write queries will stop their execution with an error, and the transaction will be closed without preserving intermediate results.
133-
134-
[NOTE]
135-
====
136-
This behaviour will be changed in the next stable version of TypeDB:
149+
- Read queries will return `206 Partial Content` with all the answers processed;
150+
- Write queries will be fully executed, and their changes can be committed.
151+
The results will be returned with `206 Partial Content`.
137152

138-
- Write queries will be fully executed, and their changes can be committed. The results will be returned with the `206 Partial Content` code.
139153
====
140154
141155
For example:

manual/modules/ROOT/pages/migration/2_to_3.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
= TypeDB 2.x to 3.0
1+
= TypeDB 2.x to 3.x
22

3-
TypeDB 3.0 is a major leap forward, offering significantly improved performance and introducing a wide range of changes across almost every aspect of the database.
3+
TypeDB 3.x is a major leap forward, offering significantly improved performance and introducing a wide range of changes across almost every aspect of the database.
44
This page outlines the key updates you should know, alongside recommendations for server and driver upgrades.
55

66
== Migration process
@@ -36,7 +36,9 @@ Click on a feature below for detailed documentation and examples.
3636

3737
* **Sessions Removed:** Connections to TypeDB now only require opening a `schema`, `write`, or `read` xref:{page-version}@manual::queries/transactions.adoc[transaction].
3838
* **Integer Value Type Renamed:** `long` is now xref:{page-version}@typeql::values/integer.adoc[`integer`].
39-
* **Kinds Introduced:** no more predefined root types and their subtyping through `person sub entity`, `friendship sub relation`, or `name sub attribute`. Each new type should be declared with an explicit kind: `entity person`, `relation friendship`, and `attribute name`. Check out xref:{page-version}@manual::schema/schema_structure.adoc[] for more.
39+
* **Kinds Introduced:** no more predefined root types and their subtyping through `person sub entity`, `friendship sub relation`, or `name sub attribute`.
40+
Each new type should be declared with an explicit kind: `entity person`, `relation friendship`, and `attribute name`.
41+
Check out xref:{page-version}@manual::schema/schema_structure.adoc[] for more.
4042
* **Expanded User Management:** Authorization and user management are now included in all TypeDB editions.
4143
Default credentials, if applicable, can be found in the xref:{page-version}@manual::connect/index.adoc[Connection Manual].
4244
* **Updated Query Syntax:**
@@ -80,20 +82,18 @@ Take into account that some of your processes can be blocked if you previously r
8082

8183
* Database import and export tools.
8284
* Configuration files (use CLI as a temporary solution).
83-
* Transaction options.
84-
* `update` queries (use `delete` + `insert` as a workaround).
85-
* `contains` and `like` operators for `string` s.
86-
* Instantiation restriction for inherited `owns` and `plays` (used to `as`). A better way is planned to be released in the future (NOTE: you don't need the `as` keyword to <<#_specialize, specialize>> an ownership of an inherited super attribute type with an ownership of its subtype).
85+
* Instantiation restriction for inherited `owns` and `plays` (used to `as`).
86+
A better way is planned to be released in the future (NOTE: you don't need the `as` keyword to <<#_specialize, specialize>> an ownership of an inherited super attribute type with an ownership of its subtype).
8787
* Scaling support for Cloud and Enterprise editions.
8888

8989
=== TypeDB Drivers
9090

9191
* Node.js, C, C++, and C# drivers are not yet available.
92+
Consider using one of xref:{page-version}@drivers::index.adoc[the available languages] or xref:{page-version}@drivers::http/index.adoc[the HTTP Endpoint].
9293

9394
=== TypeDB Studio
9495

95-
* **Graph visualizer** has been disabled due to incoming migration to an xref:{page-version}@manual::tools/code.adoc[IDE plugin]. Please consider using side tools for graph visualization if required.
96-
* **Type browser** is temporarily unavailable and planned to be reimplemented in the xref:{page-version}@manual::tools/code.adoc[IDE plugin].
96+
* **Graph visualizer** and **Type browser** are temporarily unavailable, but will be reimplemented and enhanced in the new TypeDB Studio soon.
9797

9898
[#_having_troubles]
9999
== Having troubles?

0 commit comments

Comments
 (0)