-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from madelson/release-2.5.1
Release 2.5.1
- Loading branch information
Showing
22 changed files
with
1,157 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
using Azure.Storage.Blobs.Specialized; | ||
using Azure; | ||
using Azure.Storage.Blobs.Specialized; | ||
using Medallion.Threading.Internal; | ||
|
||
namespace Medallion.Threading.Azure; | ||
|
||
/// <summary> | ||
/// Adds <see cref="SyncViaAsync"/> support to <see cref="BlobLeaseClient"/> | ||
/// </summary> | ||
internal sealed class BlobLeaseClientWrapper | ||
internal sealed class BlobLeaseClientWrapper(BlobLeaseClient blobLeaseClient) | ||
{ | ||
private readonly BlobLeaseClient _blobLeaseClient; | ||
public string LeaseId => blobLeaseClient.LeaseId; | ||
|
||
public BlobLeaseClientWrapper(BlobLeaseClient blobLeaseClient) | ||
public ValueTask<Response> AcquireAsync(TimeoutValue duration, CancellationToken cancellationToken) | ||
{ | ||
this._blobLeaseClient = blobLeaseClient; | ||
} | ||
|
||
public string LeaseId => this._blobLeaseClient.LeaseId; | ||
|
||
public ValueTask AcquireAsync(TimeoutValue duration, CancellationToken cancellationToken) | ||
{ | ||
if (SyncViaAsync.IsSynchronous) | ||
RequestContext requestContext = new() | ||
{ | ||
this._blobLeaseClient.Acquire(duration.TimeSpan, cancellationToken: cancellationToken); | ||
return default; | ||
} | ||
return new ValueTask(this._blobLeaseClient.AcquireAsync(duration.TimeSpan, cancellationToken: cancellationToken)); | ||
CancellationToken = cancellationToken, | ||
ErrorOptions = ErrorOptions.NoThrow | ||
}; | ||
|
||
return SyncViaAsync.IsSynchronous | ||
? new ValueTask<Response>(blobLeaseClient.Acquire(duration.TimeSpan, conditions: null, requestContext)) | ||
: new ValueTask<Response>(blobLeaseClient.AcquireAsync(duration.TimeSpan, conditions: null, requestContext)); | ||
} | ||
|
||
public ValueTask RenewAsync(CancellationToken cancellationToken) | ||
{ | ||
if (SyncViaAsync.IsSynchronous) | ||
{ | ||
this._blobLeaseClient.Renew(cancellationToken: cancellationToken); | ||
blobLeaseClient.Renew(cancellationToken: cancellationToken); | ||
return default; | ||
} | ||
return new ValueTask(this._blobLeaseClient.RenewAsync(cancellationToken: cancellationToken)); | ||
return new ValueTask(blobLeaseClient.RenewAsync(cancellationToken: cancellationToken)); | ||
} | ||
|
||
public ValueTask ReleaseAsync() | ||
{ | ||
if (SyncViaAsync.IsSynchronous) | ||
{ | ||
this._blobLeaseClient.Release(); | ||
blobLeaseClient.Release(); | ||
return default; | ||
} | ||
return new ValueTask(this._blobLeaseClient.ReleaseAsync()); | ||
return new ValueTask(blobLeaseClient.ReleaseAsync()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.