-
Notifications
You must be signed in to change notification settings - Fork 481
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
Implementation of Teams batch APIs #6655
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ff44825
Add SendMessageToListOfUsersAsync method
ceciliaavila 8061b16
Add unit test for SendMessageToListOfUsersAsync
ceciliaavila adf8b03
Add retry logic to SendMessageToListOfUsersAsync
ceciliaavila fbb5b7d
Implementation of SendMessageToAllUsersInTenant
JhontSouth a45f6b3
Implementation of SendMessageToAllUsersInTeam operation
JhontSouth b5d83c1
Implementation of SendMessageToListOfChannels operation
JhontSouth c295eb4
Implementation of GetOperationState operation
JhontSouth c70cd2b
Add GetPagedFailedEntriesAsync method.
ceciliaavila 2ee6b5c
Refactor to reuse code
JhontSouth 2931f5c
add response content validation
JhontSouth f0ebe7d
Add missing retryAfter property.
ceciliaavila 94ad1d1
Create TeamMember model and apply small feedback
ceciliaavila 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 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.Bot.Connector.Authentication; | ||
|
||
namespace Microsoft.Bot.Connector | ||
{ | ||
/// <summary> | ||
/// Retries asynchronous operations. In case of errors, it collects and returns exceptions in an AggregateException object. | ||
/// </summary> | ||
public static class RetryAction | ||
{ | ||
/// <summary> | ||
/// Starts the retry of the action requested. | ||
/// </summary> | ||
/// <typeparam name="TResult">The result expected from the action performed.</typeparam> | ||
/// <param name="task">A reference to the action to retry.</param> | ||
/// <param name="retryExceptionHandler">A reference to the method that handles exceptions.</param> | ||
/// <returns>A result object.</returns> | ||
public static async Task<TResult> RunAsync<TResult>(Func<Task<TResult>> task, Func<Exception, int, RetryParams> retryExceptionHandler) | ||
{ | ||
RetryParams retry; | ||
var exceptions = new List<Exception>(); | ||
var currentRetryCount = 0; | ||
|
||
do | ||
{ | ||
try | ||
{ | ||
return await task().ConfigureAwait(false); | ||
} | ||
#pragma warning disable CA1031 // Do not catch general exception types (this is a generic catch all to handle retries) | ||
catch (Exception ex) | ||
#pragma warning restore CA1031 // Do not catch general exception types | ||
{ | ||
exceptions.Add(ex); | ||
retry = retryExceptionHandler(ex, currentRetryCount); | ||
} | ||
|
||
if (retry.ShouldRetry) | ||
{ | ||
currentRetryCount++; | ||
await Task.Delay(retry.RetryAfter.WithJitter()).ConfigureAwait(false); | ||
} | ||
} | ||
while (retry.ShouldRetry); | ||
|
||
throw new AggregateException("Failed to perform the required operation.", exceptions); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're using object and not specifying a concrete type for list of members?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We created a TeamMember model with a string Id property to handle this.