OctopusDeploy / Halibut

| Public | A secure communication stack for .NET using JSON-RPC over SSL.
Other
12 stars 44 forks source link

Await using #436

Closed sburmanoctopus closed 1 year ago

sburmanoctopus commented 1 year ago

[sc-53211]

Background

Continuing on from making disposing async, we need to make disposal with using statements become async.

Results

Related to https://github.com/OctopusDeploy/Issues/issues/8266

Before

Whenever something that supports async operations is disposed, it does the disposal synchronously on the thread. This blocks the thread if disposal involves things like IO.

After

We now try to use await using instead of using do that any asynchronous operations done during disposal will no longer block the calling thread.

.NET 4.8 Complications

Streams in .NET 4.8 do not support IAsyncDisposable. This means we cannot add await to using statements.

This was fixed by wrapping the await in a #if

RewindableBufferStream

We also made RewindableBufferStream implement IAsyncDisposable. This allowed us to using await using whenever we interacted with this type of stream.

Using Our Streams

We made all our streams extend IAsyncDisposable so that they would work in .NET 4.8 with await using

How to review this PR

Quality :heavy_check_mark:

Pre-requisites

shortcut-integration[bot] commented 1 year ago

This pull request has been linked to Shortcut Story #53211: πŸŽ‰ πŸŽ‰ πŸŽ‰ Make Halibut Support Async RPC Calls πŸŽ‰ πŸŽ‰ πŸŽ‰.

nathanwoctopusdeploy commented 1 year ago

[sc-57124]

shortcut-integration[bot] commented 1 year ago

This pull request has been linked to Shortcut Story #57124: Make Dispose methods async e.g. SecureListeningClient and SecureConnection and MessageExchange[Stream/protocol] https://octopusdeploy.slack.com/archives/C04JFJXECS1/p1691566809002419.

shortcut-integration[bot] commented 1 year ago

This pull request has been linked to Shortcut Story #53211: πŸŽ‰ πŸŽ‰ πŸŽ‰ Make Halibut Support Async RPC Calls πŸŽ‰ πŸŽ‰ πŸŽ‰.

sburmanoctopus commented 1 year ago

[sc-57123]

shortcut-integration[bot] commented 1 year ago

This pull request has been linked to Shortcut Story #57123: RewindableBufferStream needs an async Dispose method (and that to be tested).