-
Notifications
You must be signed in to change notification settings - Fork 227
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
Async cache setting #1736
Closed
Closed
Async cache setting #1736
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 |
---|---|---|
|
@@ -19,7 +19,10 @@ | |
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.net.URISyntaxException; | ||
import java.util.Arrays; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.Callable; | ||
|
@@ -37,6 +40,7 @@ public class AsyncQueryThread implements Callable<AsyncAPIResult> { | |
private AsyncExecutorService service; | ||
private String apiVersion; | ||
|
||
|
||
public AsyncQueryThread(AsyncAPI queryObj, User user, AsyncExecutorService service, String apiVersion) { | ||
this.queryObj = queryObj; | ||
this.user = user; | ||
|
@@ -49,10 +53,13 @@ public AsyncAPIResult call() throws URISyntaxException, NoHttpResponseException | |
ElideResponse response = null; | ||
log.debug("AsyncQuery Object from request: {}", this); | ||
UUID requestUUID = UUID.fromString(queryObj.getRequestId()); | ||
Map<String, List<String>> bypassCacheMap = new HashMap<String, List<String>>(); | ||
bypassCacheMap.put("bypasscache", Arrays.asList(String.valueOf(service.isBypassCache()))); | ||
|
||
if (queryObj.getQueryType().equals(QueryType.JSONAPI_V1_0)) { | ||
response = executeJsonApiRequest(service.getElide(), user, apiVersion, requestUUID); | ||
response = executeJsonApiRequest(service.getElide(), user, apiVersion, requestUUID, bypassCacheMap); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of naming the variable bypassCacheMap, call it headers. It is a better reflection of what the map represents. |
||
} else if (queryObj.getQueryType().equals(QueryType.GRAPHQL_V1_0)) { | ||
response = executeGraphqlRequest(service.getRunners(), user, apiVersion, requestUUID); | ||
response = executeGraphqlRequest(service.getRunners(), user, apiVersion, requestUUID, bypassCacheMap); | ||
} | ||
nullResponseCheck(response); | ||
|
||
|
@@ -90,24 +97,25 @@ private String getPath(URIBuilder uri) { | |
return uri.getPath(); | ||
} | ||
|
||
private ElideResponse executeJsonApiRequest(Elide elide, User user, String apiVersion, UUID requestUUID) | ||
throws URISyntaxException { | ||
private ElideResponse executeJsonApiRequest(Elide elide, User user, String apiVersion, UUID requestUUID, | ||
Map<String, List<String>> bypassCacheMap) throws URISyntaxException { | ||
URIBuilder uri = new URIBuilder(queryObj.getQuery()); | ||
MultivaluedMap<String, String> queryParams = getQueryParams(uri); | ||
log.debug("Extracted QueryParams from AsyncQuery Object: {}", queryParams); | ||
|
||
//TODO - we need to add the baseUrlEndpoint to the queryObject. | ||
ElideResponse response = elide.get("", getPath(uri), queryParams, user, apiVersion, requestUUID); | ||
ElideResponse response = elide.get("", getPath(uri), queryParams, bypassCacheMap, user, apiVersion, | ||
requestUUID); | ||
log.debug("JSONAPI_V1_0 getResponseCode: {}, JSONAPI_V1_0 getBody: {}", | ||
response.getResponseCode(), response.getBody()); | ||
return response; | ||
} | ||
|
||
private ElideResponse executeGraphqlRequest(Map<String, QueryRunner> runners, User user, String apiVersion, | ||
UUID requestUUID) throws URISyntaxException { | ||
UUID requestUUID, Map<String, List<String>> bypassCacheMap) throws URISyntaxException { | ||
QueryRunner runner = runners.get(apiVersion); | ||
//TODO - we need to add the baseUrlEndpoint to the queryObject. | ||
ElideResponse response = runner.run("", queryObj.getQuery(), user, requestUUID); | ||
ElideResponse response = runner.run("", queryObj.getQuery(), user, requestUUID, bypassCacheMap); | ||
log.debug("GRAPHQL_V1_0 getResponseCode: {}, GRAPHQL_V1_0 getBody: {}", | ||
response.getResponseCode(), response.getBody()); | ||
return response; | ||
|
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
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
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.
Won't this always override the cache? I don't think this is the behavior that we want.