Conversation
Signed-off-by: Sander Pick <sanderpick@gmail.com>
| t.Fatalf("failed to write txn discard: %v", err) | ||
| } | ||
|
|
||
| err = txn.Save(existingPerson) |
There was a problem hiding this comment.
To be clear, this method discards the changes, but it doesn't abort the transaction itself, correct? To abort the transaction, it looks like we need to close the context, is that right?
There was a problem hiding this comment.
I ask because from a remote client perspective, this doesn't appear to be possible?
There was a problem hiding this comment.
Yep, exactly, it's still "alive" but will error when it's committed using End
| t.Fatalf("failed to start write txn: %v", err) | ||
| } | ||
| defer func() { | ||
| err = end() |
There was a problem hiding this comment.
@carsonfarmer this is calling the func returned by the Go client that actually just sends a CloseSend to the server, which makes it release the transaction... that means it will be committed, but will error if it has been marked as "discarded"
There was a problem hiding this comment.
You can see how the Go client "ends" the transaction here: https://github.com/textileio/go-threads/blob/master/api/client/write.go#L233 (note the extra error catch...)
There was a problem hiding this comment.
Yeh this is exactly what I needed. Perfect. One thing I noticed though, in the js client, we're not properly getting the final response as in here: https://github.com/textileio/go-threads/blob/master/api/client/write.go#L237 which we need to ensure the transaction was successful or not.
There was a problem hiding this comment.
So this has been a useful thread/discussion. Cheers!
There was a problem hiding this comment.
Yeah totally, I ran into that yesterday: #436 (comment)
Signed-off-by: Sander Pick sanderpick@gmail.com