Skip to content

Commit 70cfa19

Browse files
fix: migrate transaction docs and examples to transactions() API (#373)
* fix: migrate transaction docs and examples to transactions() API Move the write mode-selection Javadoc in OpenFgaClient and the example projects off the double-negative disableTransactions(boolean) to the affirmative transactions()/isTransactionsEnabled() API. Also switch the internal write mode branch to !isTransactionsEnabled() so the SDK no longer calls its own soon-to-be-deprecated method. Behavior is unchanged. Test call sites that still use disableTransactions are intentionally left for the deprecation issue, which will migrate them and keep one back-compat test under @SuppressWarnings. Refs #368 * fix: clarify write mode Javadoc for the no-options overload Address review feedback. The write(request) overload takes no options, so describing the mode as options.isTransactionsEnabled() implied a call on an absent or null options reference. Reword both overloads to key the mode off the transactions() setter and state that transactional mode is the default when no options are passed. Docs only, no behavior change. Refs #368
1 parent ed63320 commit 70cfa19

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

examples/basic-examples/src/main/java/dev/openfga/sdk/example/Example1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void run(String apiUrl) throws Exception {
117117
// relation
118118
)),
119119
new ClientWriteOptions()
120-
.disableTransactions(true)
120+
.transactions(false)
121121
.authorizationModelId(authorizationModel.getAuthorizationModelId()))
122122
.get();
123123
System.out.println("Done Writing Tuples");

examples/basic-examples/src/main/kotlin/dev/openfga/sdk/example/KotlinExample1.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ internal class KotlinExample1 {
117117
)
118118
),
119119
ClientWriteOptions()
120-
.disableTransactions(true)
120+
.transactions(false)
121121
.authorizationModelId(authorizationModel.authorizationModelId)
122122
)
123123
.get()

src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public CompletableFuture<ClientReadResponse> read(ClientReadRequest request, Cli
412412
* <p>This method can operate in two modes depending on the options provided:</p>
413413
*
414414
* <h3>Transactional Mode (default)</h3>
415-
* <p>When {@code options.disableTransactions()} is false or not set:</p>
415+
* <p>Used by default, when no options are passed or when {@code transactions(true)} is set:</p>
416416
* <ul>
417417
* <li>All writes and deletes are executed as a single atomic transaction</li>
418418
* <li>If any tuple fails, the entire operation fails and no changes are made</li>
@@ -421,7 +421,7 @@ public CompletableFuture<ClientReadResponse> read(ClientReadRequest request, Cli
421421
* </ul>
422422
*
423423
* <h3>Non-Transactional Mode</h3>
424-
* <p>When {@code options.disableTransactions()} is true:</p>
424+
* <p>Used when {@code transactions(false)} is set on the options:</p>
425425
* <ul>
426426
* <li>Tuples are processed in chunks (size controlled by {@code transactionChunkSize})</li>
427427
* <li>Each chunk is processed independently - some may succeed while others fail</li>
@@ -466,7 +466,7 @@ public CompletableFuture<ClientWriteResponse> write(ClientWriteRequest request)
466466
* <p>This method can operate in two modes depending on the options provided:</p>
467467
*
468468
* <h3>Transactional Mode (default)</h3>
469-
* <p>When {@code options.disableTransactions()} is false or not set:</p>
469+
* <p>Used by default, when no options are passed or when {@code transactions(true)} is set:</p>
470470
* <ul>
471471
* <li>All writes and deletes are executed as a single atomic transaction</li>
472472
* <li>If any tuple fails, the entire operation fails and no changes are made</li>
@@ -475,7 +475,7 @@ public CompletableFuture<ClientWriteResponse> write(ClientWriteRequest request)
475475
* </ul>
476476
*
477477
* <h3>Non-Transactional Mode</h3>
478-
* <p>When {@code options.disableTransactions()} is true:</p>
478+
* <p>Used when {@code transactions(false)} is set on the options:</p>
479479
* <ul>
480480
* <li>Tuples are processed in chunks (size controlled by {@code transactionChunkSize})</li>
481481
* <li>Each chunk is processed independently - some may succeed while others fail</li>
@@ -515,7 +515,7 @@ public CompletableFuture<ClientWriteResponse> write(ClientWriteRequest request,
515515
configuration.assertValid();
516516
String storeId = configuration.getStoreIdChecked();
517517

518-
if (options != null && options.disableTransactions()) {
518+
if (options != null && !options.isTransactionsEnabled()) {
519519
return writeNonTransaction(storeId, request, options);
520520
}
521521

src/test-integration/java/dev/openfga/sdk/example/Example1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void run(String apiUrl) throws Exception {
117117
// relation
118118
)),
119119
new ClientWriteOptions()
120-
.disableTransactions(true)
120+
.transactions(false)
121121
.authorizationModelId(authorizationModel.getAuthorizationModelId()))
122122
.get();
123123
System.out.println("Done Writing Tuples");

0 commit comments

Comments
 (0)