-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add support for settlement from the isolated worker extension #38865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b0a63c3
Add support for settlement from the isolated worker extension
JoshLove-msft 306e7a4
Merge branch 'main' of https://github.com/azure/azure-sdk-for-net int…
JoshLove-msft 9110a76
Update comment
JoshLove-msft 58660cb
roll back version of Grpc.Tools
JoshLove-msft 9b257df
roll back further
JoshLove-msft 002767d
PR fb
JoshLove-msft a114220
Revert eventArgs fields to private
JoshLove-msft 07067b7
remove in finally block
JoshLove-msft 6b6bd33
Fix test and move versions to package.data.props
JoshLove-msft d8405f6
Update sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/s…
JoshLove-msft c1097c0
Add batch test cases
JoshLove-msft 619ee14
Fix tests
JoshLove-msft 1d65c95
Fix
JoshLove-msft cdec937
PR fb
JoshLove-msft ccf84a2
fix
JoshLove-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
28 changes: 28 additions & 0 deletions
28
...ebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Grpc/Proto/SettlementExtensions.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #if NET6_0_OR_GREATER | ||
| using Microsoft.Azure.ServiceBus.Grpc; | ||
|
|
||
| namespace Microsoft.Azure.WebJobs.Extensions.ServiceBus.Grpc | ||
| { | ||
| internal static class SettlementExtensions | ||
| { | ||
| internal static object GetPropertyValue(this SettlementProperties properties) | ||
| { | ||
| return properties.ValuesCase switch | ||
| { | ||
| SettlementProperties.ValuesOneofCase.LongValue => properties.LongValue, | ||
| SettlementProperties.ValuesOneofCase.UlongValue => properties.UlongValue, | ||
| SettlementProperties.ValuesOneofCase.DoubleValue => properties.DoubleValue, | ||
| SettlementProperties.ValuesOneofCase.FloatValue => properties.FloatValue, | ||
| SettlementProperties.ValuesOneofCase.IntValue => properties.IntValue, | ||
| SettlementProperties.ValuesOneofCase.UintValue => properties.UintValue, | ||
| SettlementProperties.ValuesOneofCase.BoolValue => properties.BoolValue, | ||
| SettlementProperties.ValuesOneofCase.StringValue => properties.StringValue, | ||
| _ => null | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| #endif |
66 changes: 66 additions & 0 deletions
66
sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Grpc/Proto/settlement.proto
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| import "google/protobuf/timestamp.proto"; | ||
| import "google/protobuf/empty.proto"; | ||
|
|
||
| // this namespace will be shared between isolated worker and WebJobs extension so make it somewhat generic | ||
| option csharp_namespace = "Microsoft.Azure.ServiceBus.Grpc"; | ||
|
|
||
| // The settlement service definition. | ||
| service Settlement { | ||
| // Completes a message | ||
| rpc Complete (CompleteRequest) returns (google.protobuf.Empty) {} | ||
|
|
||
| // Abandons a message | ||
| rpc Abandon (AbandonRequest) returns (google.protobuf.Empty) {} | ||
|
|
||
| // Deadletters a message | ||
| rpc Deadletter (DeadletterRequest) returns (google.protobuf.Empty) {} | ||
|
|
||
| // Defers a message | ||
| rpc Defer (DeferRequest) returns (google.protobuf.Empty) {} | ||
| } | ||
|
|
||
| // The complete message request containing the locktoken. | ||
| message CompleteRequest { | ||
| string locktoken = 1; | ||
| } | ||
|
|
||
| // The abandon message request containing the locktoken and properties to modify. | ||
| message AbandonRequest { | ||
| string locktoken = 1; | ||
| map<string, SettlementProperties> propertiesToModify = 2; | ||
| } | ||
|
|
||
| // The deadletter message request containing the locktoken and properties to modify along with the reason/description. | ||
| message DeadletterRequest { | ||
| string locktoken = 1; | ||
| map<string, SettlementProperties> propertiesToModify = 2; | ||
| string deadletterReason = 3; | ||
| string deadletterErrorDescription = 4; | ||
| } | ||
|
|
||
| // The defer message request containing the locktoken and properties to modify. | ||
| message DeferRequest { | ||
| string locktoken = 1; | ||
| map<string, SettlementProperties> propertiesToModify = 2; | ||
| } | ||
|
|
||
| // The settlement property can be of any type listed below, which | ||
| // corresponds to the types specified in | ||
| // https://learn.microsoft.com/en-us/dotnet/api/azure.messaging.servicebus.servicebusmessage.applicationproperties?view=azure-dotnet#remarks | ||
| // Note: this list doesn't match 1:1 with the supported Service Bus types, so compatible types are used in some cases - e.g. | ||
| // short uses int, TimeSpan uses string, etc. The full list of transforms can be found in the isolated worker extension source code. | ||
| message SettlementProperties { | ||
| oneof values { | ||
| string stringValue = 1; | ||
| int32 intValue = 2; | ||
| uint32 uintValue = 3; | ||
| int64 longValue = 4; | ||
| uint64 ulongValue = 5; | ||
| bool boolValue = 6; | ||
| float floatValue = 7; | ||
| double doubleValue = 8; | ||
| google.protobuf.Timestamp timestampValue = 9; | ||
| } | ||
| } |
89 changes: 89 additions & 0 deletions
89
sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Grpc/SettlementService.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #if NET6_0_OR_GREATER | ||
| using System; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Google.Protobuf.WellKnownTypes; | ||
| using Grpc.Core; | ||
| using Microsoft.Azure.ServiceBus.Grpc; | ||
| using Microsoft.Azure.WebJobs.ServiceBus; | ||
|
|
||
| namespace Microsoft.Azure.WebJobs.Extensions.ServiceBus.Grpc | ||
| { | ||
| internal class SettlementService : Settlement.SettlementBase | ||
| { | ||
| private readonly MessagingProvider _provider; | ||
|
|
||
| public SettlementService(MessagingProvider provider) | ||
| { | ||
| _provider = provider; | ||
| } | ||
|
|
||
| public SettlementService() | ||
| { | ||
| _provider = null; | ||
| } | ||
|
|
||
| public override async Task<Empty> Complete(CompleteRequest request, ServerCallContext context) | ||
| { | ||
| if (_provider.ActionsCache.TryGetValue(request.Locktoken, out var tuple)) | ||
| { | ||
| await tuple.Actions.CompleteMessageAsync( | ||
| tuple.Message, | ||
| context.CancellationToken).ConfigureAwait(false); | ||
| return new Empty(); | ||
| } | ||
| throw new RpcException (new Status(StatusCode.FailedPrecondition, $"LockToken {request.Locktoken} not found.")); | ||
| } | ||
|
|
||
| public override async Task<Empty> Abandon(AbandonRequest request, ServerCallContext context) | ||
| { | ||
| if (_provider.ActionsCache.TryGetValue(request.Locktoken, out var tuple)) | ||
| { | ||
| await tuple.Actions.AbandonMessageAsync( | ||
| tuple.Message, | ||
| request.PropertiesToModify.ToDictionary( | ||
| pair => pair.Key, | ||
| pair => pair.Value.GetPropertyValue()), | ||
| context.CancellationToken).ConfigureAwait(false); | ||
| return new Empty(); | ||
| } | ||
| throw new RpcException (new Status(StatusCode.FailedPrecondition, $"LockToken {request.Locktoken} not found.")); | ||
| } | ||
|
|
||
| public override async Task<Empty> Defer(DeferRequest request, ServerCallContext context) | ||
| { | ||
| if (_provider.ActionsCache.TryGetValue(request.Locktoken, out var tuple)) | ||
| { | ||
| await tuple.Actions.DeferMessageAsync( | ||
| tuple.Message, | ||
| request.PropertiesToModify.ToDictionary( | ||
| pair => pair.Key, | ||
| pair => pair.Value.GetPropertyValue()), | ||
| context.CancellationToken).ConfigureAwait(false); | ||
| return new Empty(); | ||
| } | ||
| throw new RpcException (new Status(StatusCode.FailedPrecondition, $"LockToken {request.Locktoken} not found.")); | ||
| } | ||
|
|
||
| public override async Task<Empty> Deadletter(DeadletterRequest request, ServerCallContext context) | ||
| { | ||
| if (_provider.ActionsCache.TryGetValue(request.Locktoken, out var tuple)) | ||
| { | ||
| await tuple.Actions.DeadLetterMessageAsync( | ||
| tuple.Message, | ||
| request.PropertiesToModify.ToDictionary( | ||
| pair => pair.Key, | ||
| pair => pair.Value.GetPropertyValue()), | ||
| request.DeadletterReason, | ||
| request.DeadletterErrorDescription, | ||
| context.CancellationToken).ConfigureAwait(false); | ||
| return new Empty(); | ||
| } | ||
| throw new RpcException (new Status(StatusCode.FailedPrecondition, $"LockToken {request.Locktoken} not found.")); | ||
| } | ||
| } | ||
| } | ||
| #endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.