In the Google Cloud Spanner Java API, the only way to perform read/write transactions is by providing a callback, via the TransactionRunner interface.
I understand that the API is trying to hide the details of the need to automatically retry transactions as a convenience to the programmer, but this limitation is a serious problem, at least for me. I need to be able to manage the transaction lifecycle myself, even if that means I have to perform my own retries (e.g., based on catching some sort of "retryable" exception, in this case AbortedException).
To make this problem more concrete, suppose one wanted to implement Spring's PlatformTransactionManager for Google Cloud Spanner, so as to fit in with one's existing code, and use one's existing retry logic. It would not be possible with the current API.
It would be easy to augment the API in a backward compatible way, by adding a method returning a TransactionContext directly to the user, and let the user handle the retries. Of course this new method could be documented as "more dangerous and less convenient" to scare away noobs, etc.
Can this alternate (more traditional) transaction API style be added to the Java API?
Thanks.
In the Google Cloud Spanner Java API, the only way to perform read/write transactions is by providing a callback, via the
TransactionRunnerinterface.I understand that the API is trying to hide the details of the need to automatically retry transactions as a convenience to the programmer, but this limitation is a serious problem, at least for me. I need to be able to manage the transaction lifecycle myself, even if that means I have to perform my own retries (e.g., based on catching some sort of "retryable" exception, in this case
AbortedException).To make this problem more concrete, suppose one wanted to implement Spring's PlatformTransactionManager for Google Cloud Spanner, so as to fit in with one's existing code, and use one's existing retry logic. It would not be possible with the current API.
It would be easy to augment the API in a backward compatible way, by adding a method returning a
TransactionContextdirectly to the user, and let the user handle the retries. Of course this new method could be documented as "more dangerous and less convenient" to scare away noobs, etc.Can this alternate (more traditional) transaction API style be added to the Java API?
Thanks.