@@ -223,35 +223,26 @@ func (txl *TransactionLayer) NewClientTransaction(ctx context.Context, req *Requ
223223}
224224
225225func (txl * TransactionLayer ) clientTxRequest (ctx context.Context , req * Request , key string ) (* ClientTx , error ) {
226+ conn , err := txl .tpl .ClientRequestConnection (ctx , req )
227+ if err != nil {
228+ return nil , fmt .Errorf ("client transcation failed to request connection: %w" , err )
229+ }
230+
226231 txl .clientTransactions .lock ()
227232 tx , exists := txl .clientTransactions .items [key ]
228233 if exists {
229234 txl .clientTransactions .unlock ()
235+ conn .TryClose ()
230236 return nil , fmt .Errorf ("client transaction %q already exists" , key )
231237 }
232-
233- tx , err := txl .clientTxCreate (ctx , req , key )
234- if err != nil {
235- txl .clientTransactions .unlock ()
236- return nil , fmt .Errorf ("failed to create client transaction: %w" , err )
237- }
238+ tx = NewClientTx (key , req , conn , txl .log )
238239
239240 txl .clientTransactions .items [key ] = tx
240241 tx .OnTerminate (txl .clientTxTerminate )
241242 txl .clientTransactions .unlock ()
242243 return tx , nil
243244}
244245
245- func (txl * TransactionLayer ) clientTxCreate (ctx context.Context , req * Request , key string ) (* ClientTx , error ) {
246- conn , err := txl .tpl .ClientRequestConnection (ctx , req )
247- if err != nil {
248- return nil , err
249- }
250-
251- tx := NewClientTx (key , req , conn , txl .log )
252- return tx , nil
253- }
254-
255246func (txl * TransactionLayer ) Respond (res * Response ) (* ServerTx , error ) {
256247 key , err := MakeServerTxKey (res )
257248 if err != nil {
0 commit comments