-
Notifications
You must be signed in to change notification settings - Fork 194
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 #802 from cagil-ozdemirag-mw/feature/multithreadin…
…g_issues Feature/multithreading issues
- Loading branch information
Showing
47 changed files
with
690 additions
and
444 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
58 changes: 58 additions & 0 deletions
58
Source/FikaAmazonAPI/AmazonMultithreadedConnectionFactory.cs
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,58 @@ | ||
using FikaAmazonAPI.Utils; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace FikaAmazonAPI | ||
{ | ||
public class AmazonMultithreadedConnectionFactory | ||
{ | ||
private readonly string _accessKey; | ||
private readonly string _secretKey; | ||
private readonly string _roleArn; | ||
private readonly string _clientId; | ||
private readonly string _clientSecret; | ||
private readonly string _refreshToken; | ||
private readonly string _proxyAddress; | ||
|
||
private readonly IRateLimitingHandler _rateLimitingHandler; | ||
|
||
public AmazonMultithreadedConnectionFactory( | ||
string ClientId, | ||
string ClientSecret, | ||
string RefreshToken, | ||
string AccessKey = null, | ||
string SecretKey = null, | ||
string RoleArn = null, | ||
string ProxyAddress = null, | ||
IRateLimitingHandler rateLimitingHandler = null) | ||
{ | ||
_accessKey = AccessKey; | ||
_secretKey = SecretKey; | ||
_roleArn = RoleArn; | ||
_clientId = ClientId; | ||
_clientSecret = ClientSecret; | ||
_refreshToken = RefreshToken; | ||
_proxyAddress = ProxyAddress; | ||
|
||
_rateLimitingHandler = rateLimitingHandler ?? new RateLimitingHandler(); | ||
} | ||
|
||
public AmazonConnection RequestScopedConnection( | ||
string marketPlaceId = null, | ||
string sellerId = null, | ||
string refCode = null, | ||
Action<AmazonCredential> credentialConfiguration = null, | ||
CultureInfo cultureInfo = null) | ||
{ | ||
// need to create distinct credential/connection here so that token caching in credential is predicably kept within scope | ||
var credential = new AmazonCredential(_accessKey, _secretKey, _roleArn, _clientId, _clientSecret, _refreshToken, _proxyAddress) | ||
{ | ||
MarketPlaceID = marketPlaceId, | ||
SellerID = sellerId, | ||
}; | ||
credentialConfiguration?.Invoke(credential); | ||
|
||
return new AmazonConnection(credential, _rateLimitingHandler, refCode, cultureInfo); | ||
} | ||
} | ||
} |
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
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.