Skip to content

Commit

Permalink
Rename requestMessage parameter to baseRequestMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed May 16, 2024
1 parent 922a9b7 commit 212beda
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class TestException : Exception;
public class TestRequestExecutionPolicy : IRequestExecutionPolicy
{
public Task<RequestResult<T>> Run<T>(
CloneableRequestMessage requestMessage,
CloneableRequestMessage baseRequestMessage,
ExecuteRequestAsync<T> executeRequestAsync,
CancellationToken cancellationToken,
int? graphqlQueryCost = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace ShopifySharp;

public class DefaultRequestExecutionPolicy : IRequestExecutionPolicy
{
public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage request, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null)
public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage baseRequestMessage, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null)
{
var fullResult = await executeRequestAsync(request);
var fullResult = await executeRequestAsync(baseRequestMessage);

return fullResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace ShopifySharp;
/// </summary>
public interface IRequestExecutionPolicy
{
/// <param name="requestMessage">The base request that was built by a service to execute.</param>
/// <param name="baseRequestMessage">The base request that was built by a service to execute.</param>
/// <param name="executeRequestAsync">A delegate that executes the request you pass to it.</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <param name="graphqlQueryCost">Optional expected Graphql query cost (as seen in GraphQL response at extensions.cost.requestedQueryCost</param>
Task<RequestResult<T>> Run<T>(CloneableRequestMessage requestMessage, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null);
Task<RequestResult<T>> Run<T>(CloneableRequestMessage baseRequestMessage, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ public LeakyBucketExecutionPolicy(int maxRetriesPerNonLimitedRequest, bool retry
_getRequestContext = getRequestContext ?? (() => RequestContext.Foreground);
}

public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage baseRequest, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null)
public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage baseRequestMessage, ExecuteRequestAsync<T> executeRequestAsync, CancellationToken cancellationToken, int? graphqlQueryCost = null)
{
var accessToken = GetAccessToken(baseRequest);
var accessToken = GetAccessToken(baseRequestMessage);
var bucket = accessToken == null ? null : _shopAccessTokenToLeakyBucket.GetOrAdd(accessToken, _ => new MultiShopifyApiBucket(_getRequestContext));
var apiType = ApiType.RestAdmin;

if (baseRequest?.RequestUri?.AbsolutePath.EndsWith("graphql.json") == true)
apiType = baseRequest.RequestUri.Host == "partners.shopify.com" ? ApiType.GraphQlPartner : ApiType.GraphQlAdmin;
if (baseRequestMessage?.RequestUri?.AbsolutePath.EndsWith("graphql.json") == true)
apiType = baseRequestMessage.RequestUri.Host == "partners.shopify.com" ? ApiType.GraphQlPartner : ApiType.GraphQlAdmin;

return apiType switch
{
Expand All @@ -91,17 +91,17 @@ public async Task<RequestResult<T>> Run<T>(CloneableRequestMessage baseRequest,
// If the user didn't pass a request query cost, we assume a cost of 50
graphqlQueryCost ?? 50,
bucket,
baseRequest),
baseRequestMessage),
ApiType.RestAdmin => await ExecuteRestAdminRequest(
executeRequestAsync,
cancellationToken,
bucket,
baseRequest),
baseRequestMessage),
ApiType.GraphQlPartner => await ExecuteGraphPartnerRequest(
executeRequestAsync,
cancellationToken,
bucket,
baseRequest),
baseRequestMessage),
_ => throw new ArgumentOutOfRangeException()
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public RetryExecutionPolicy(bool retryOnlyIfLeakyBucketFull = true)
}

public async Task<RequestResult<T>> Run<T>(
CloneableRequestMessage baseRequest,
CloneableRequestMessage baseRequestMessage,
ExecuteRequestAsync<T> executeRequestAsync,
CancellationToken cancellationToken,
int? graphqlQueryCost = null
Expand All @@ -53,7 +53,7 @@ public async Task<RequestResult<T>> Run<T>(

while (true)
{
using var request = await baseRequest.CloneAsync();
using var request = await baseRequestMessage.CloneAsync();

try
{
Expand Down

0 comments on commit 212beda

Please sign in to comment.