Skip to content

Commit a4540c6

Browse files
fix: deprecate disableTransactions in favour of transactions and isTransactionsEnabled
1 parent fb6c59f commit a4540c6

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

src/main/java/dev/openfga/sdk/api/configuration/ClientWriteOptions.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,57 @@ public String getAuthorizationModelId() {
3131
return authorizationModelId;
3232
}
3333

34+
/**
35+
* Sets whether transactions should be used when writing tuples.
36+
*
37+
* <p>When {@code true}, writes are sent as a single transactional request. When {@code false},
38+
* writes are split into chunks and sent as individual non-transactional requests, with chunk
39+
* size controlled by {@link #transactionChunkSize(int)}.
40+
*
41+
* @param enabled {@code true} to enable transactions (default), {@code false} to disable them
42+
* @return this {@code ClientWriteOptions} instance for method chaining
43+
* @see #isTransactionsEnabled()
44+
*/
45+
public ClientWriteOptions transactions(boolean enabled) {
46+
this.disableTransactions = !enabled;
47+
return this;
48+
}
49+
50+
/**
51+
* Returns whether transactions are enabled for write operations.
52+
*
53+
* @return {@code true} if transactions are enabled (default), {@code false} if disabled
54+
* @see #transactions(boolean)
55+
*/
56+
public boolean isTransactionsEnabled() {
57+
return disableTransactions == null || !disableTransactions;
58+
}
59+
60+
/**
61+
* Sets whether transactions should be disabled when writing tuples.
62+
*
63+
* @param disableTransactions {@code true} to disable transactions, {@code false} to enable them
64+
* @return this {@code ClientWriteOptions} instance for method chaining
65+
* @deprecated Use {@link #transactions(boolean)} instead. This method will be removed in a
66+
* future release. Replace {@code disableTransactions(true)} with
67+
* {@code transactions(false)}, and {@code disableTransactions(false)} with
68+
* {@code transactions(true)}.
69+
*/
70+
@Deprecated
3471
public ClientWriteOptions disableTransactions(boolean disableTransactions) {
3572
this.disableTransactions = disableTransactions;
3673
return this;
3774
}
3875

76+
/**
77+
* Returns whether transactions are disabled for write operations.
78+
*
79+
* @return {@code true} if transactions are disabled, {@code false} if enabled (default)
80+
* @deprecated Use {@link #isTransactionsEnabled()} instead. This method will be removed in a
81+
* future release. Note that {@code isTransactionsEnabled()} returns the inverse of
82+
* this method.
83+
*/
84+
@Deprecated
3985
public boolean disableTransactions() {
4086
return disableTransactions != null && disableTransactions;
4187
}

0 commit comments

Comments
 (0)