Skip to content

Added asynchronous transaction savepoint functions. - #2414

Merged
roji merged 1 commit into
npgsql:devfrom
chriswebb:async-transaction-savepoints
Apr 5, 2019
Merged

roji merged 1 commit into
npgsql:devfrom
chriswebb:async-transaction-savepoints

Conversation

@chriswebb

Copy link
Copy Markdown
Contributor

Hey I noticed the asynchronous version of the savepoint functions were missing, so I went ahead and created them and some tests. Let me know if this is unwanted or if you have any suggestions about format / styling etc.

Chris

@YohDeadfall YohDeadfall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I don't think that there is need in nested regions like Save Savepoints.

@YohDeadfall YohDeadfall added this to the 4.1 milestone Apr 3, 2019
Comment thread src/Npgsql/NpgsqlTransaction.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not combine these two with a default argument?

@YohDeadfall YohDeadfall Apr 3, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how public API is designed. Take a look at other methods in System.Data or in 'Npgsql'. An explanation of that you can found here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, interesting. In that case, please disregard!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YohDeadfall it's true that this is how System.Data is currently, but that's pretty old. The corefx guidelines have changed and it's not preferred to have a single method with an optional cancellation token parameter. The same is being adopted in https://github.com/dotnet/corefx/issues/35012, for example (this was communicated orally in a .NET design review meeting).

Comment thread src/Npgsql/NpgsqlTransaction.cs Resolved
Comment thread src/Npgsql/NpgsqlTransaction.cs Resolved
Comment thread test/Npgsql.Tests/TransactionTests.cs Resolved
@chriswebb
chriswebb force-pushed the async-transaction-savepoints branch from 650783f to 89a4374 Compare April 3, 2019 21:25
@chriswebb

Copy link
Copy Markdown
Contributor Author

Perfect, I went ahead and removed the superfluous nested regions. I have the old commit saved in a branch so if anyone wants them back, I can re-do it.

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, looks good.

One change request from me - please merge together the two async overloads as @austindrenski previously wrote (see my comment below).

Comment thread src/Npgsql/NpgsqlTransaction.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this isn't the right pattern - a cancelled Task should be returned rather than throwing. However, we don't do this correctly in some other async methods, I've opened #2417 to track this separately.

Comment thread src/Npgsql/NpgsqlTransaction.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YohDeadfall it's true that this is how System.Data is currently, but that's pretty old. The corefx guidelines have changed and it's not preferred to have a single method with an optional cancellation token parameter. The same is being adopted in https://github.com/dotnet/corefx/issues/35012, for example (this was communicated orally in a .NET design review meeting).

@chriswebb
chriswebb force-pushed the async-transaction-savepoints branch from 89a4374 to 8378f58 Compare April 4, 2019 23:30
@chriswebb

Copy link
Copy Markdown
Contributor Author

Alright how does that look? I went ahead and did it for CommitAsync() and RollbackAsync() as well. Is that return cancelled task how you would like it formatted? Do you think there should be line break in between the if statement and the using?

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@roji
roji merged commit d34faf6 into npgsql:dev Apr 5, 2019
@roji

roji commented Apr 5, 2019

Copy link
Copy Markdown
Member

This is a binary breaking change as some public methods have been removed (overloads of Commit/Rollback without a cancellation token).

@roji

roji commented Aug 14, 2019

Copy link
Copy Markdown
Member

Added back the removed overloads for 4.1 only (not 5.0) to prevent the binary break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants