[
https://issues.apache.org/jira/browse/IGNITE-25403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eduard Rakhmankulov updated IGNITE-25403:
-----------------------------------------
Description:
All transactional API methods accept a Transaction. In real use, most of the
time that parameter is null making all API calls starting with (null, ... which
doesn't look good and is generally confusing. While this was to done to make
sure the user doesn't forget to pass the transaction to all methods, it looks
like this makes the API safe but too inconvenient.
It is better to add overloads for at least some of the API methods that don't
need the Transaction. It's the same as passing null.
It's OK not to add these overloads to every single method. For example, if foo
an operation foo there are two methods now
{{foo(tx, args, opts)
foo(tx, args)}}
it's OK to only add one additional convenience method
{{foo(args)}}
i.e. not to add another overload to the more detailed method that also accepts
operation options.
Compilation time conflict because of adding new overloads:
{code:java}
KeyValueView.java:
1. remove[Async](K,V) == remove[Async](Transaction, K) | example:
remove(/*Transaction*/null, /*K*/key) | unlikely | in case when typeof(K) ==
typeof(V)
2. removeAll[Async](Collection<K>) == removeAll[Async](Transaction) | example:
removeAll(/*Transaction*/ null) | CONFLICT |
3. replace[Async](K,V,V) == replace[Async](Transaction, K, V) | example:
replace(/*Transaction*/ null, key, newVal) | unlikely | in case when typeof(K)
== typeof(V)
RecordView.java:
1. deleteAll[Async](Collection<R>) == deleteAll[Async](Transaction) | example
deleteAll(/*Transaction*/ null) | CONFLICT
2. relpace[Async](R,R) == replace[Async](Transaction, R) | example
replace(/*Transaction*/ null, record) | CONFLICT {code}
was:
All transactional API methods accept a Transaction. In real use, most of the
time that parameter is null making all API calls starting with (null, ... which
doesn't look good and is generally confusing. While this was to done to make
sure the user doesn't forget to pass the transaction to all methods, it looks
like this makes the API safe but too inconvenient.
It is better to add overloads for at least some of the API methods that don't
need the Transaction. It's the same as passing null.
It's OK not to add these overloads to every single method. For example, if foo
an operation foo there are two methods now
{{foo(tx, args, opts)
foo(tx, args)}}
it's OK to only add one additional convenience method
{{foo(args)}}
i.e. not to add another overload to the more detailed method that also accepts
operation options.
> Add overloads for common API methods that don't accept Transaction
> ------------------------------------------------------------------
>
> Key: IGNITE-25403
> URL: https://issues.apache.org/jira/browse/IGNITE-25403
> Project: Ignite
> Issue Type: Improvement
> Reporter: Eduard Rakhmankulov
> Assignee: Eduard Rakhmankulov
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> All transactional API methods accept a Transaction. In real use, most of the
> time that parameter is null making all API calls starting with (null, ...
> which doesn't look good and is generally confusing. While this was to done to
> make sure the user doesn't forget to pass the transaction to all methods, it
> looks like this makes the API safe but too inconvenient.
> It is better to add overloads for at least some of the API methods that don't
> need the Transaction. It's the same as passing null.
> It's OK not to add these overloads to every single method. For example, if
> foo an operation foo there are two methods now
>
> {{foo(tx, args, opts)
> foo(tx, args)}}
> it's OK to only add one additional convenience method
>
> {{foo(args)}}
> i.e. not to add another overload to the more detailed method that also
> accepts operation options.
>
> Compilation time conflict because of adding new overloads:
> {code:java}
> KeyValueView.java:
> 1. remove[Async](K,V) == remove[Async](Transaction, K) | example:
> remove(/*Transaction*/null, /*K*/key) | unlikely | in case when typeof(K) ==
> typeof(V)
> 2. removeAll[Async](Collection<K>) == removeAll[Async](Transaction) |
> example: removeAll(/*Transaction*/ null) | CONFLICT |
> 3. replace[Async](K,V,V) == replace[Async](Transaction, K, V) | example:
> replace(/*Transaction*/ null, key, newVal) | unlikely | in case when
> typeof(K) == typeof(V)
> RecordView.java:
> 1. deleteAll[Async](Collection<R>) == deleteAll[Async](Transaction) | example
> deleteAll(/*Transaction*/ null) | CONFLICT
> 2. relpace[Async](R,R) == replace[Async](Transaction, R) | example
> replace(/*Transaction*/ null, record) | CONFLICT {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)