uri, connectionPolicy.getConnectionMode(), consistencyLevel.toString(), connectionPolicy.getRetryOptions().getMaxRetryAttemptsOnThrottledRequests(), connectionPolicy.getRetryOptions().getMaxRetryWaitTimeInSeconds(),
public RxGatewayStoreModel(ConnectionPolicy connectionPolicy, ConsistencyLevel consistencyLevel, QueryCompatibilityMode queryCompatibilityMode, String masterKey, Map<String, String> resourceTokens, UserAgentContainer userAgentContainer, EndpointManager globalEndpointManager, HttpClient<ByteBuf, ByteBuf> httpClient) { this.defaultHeaders = new HashMap<String, String>(); this.defaultHeaders.put(HttpConstants.HttpHeaders.CACHE_CONTROL, "no-cache"); this.defaultHeaders.put(HttpConstants.HttpHeaders.VERSION, HttpConstants.Versions.CURRENT_VERSION); if (userAgentContainer == null) { userAgentContainer = new UserAgentContainer(); } this.defaultHeaders.put(HttpConstants.HttpHeaders.USER_AGENT, userAgentContainer.getUserAgent()); if (consistencyLevel != null) { this.defaultHeaders.put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, consistencyLevel.toString()); } this.globalEndpointManager = globalEndpointManager; this.queryCompatibilityMode = queryCompatibilityMode; this.httpClient = httpClient; }
private void applySessionToken(RxDocumentServiceRequest request) { Map<String, String> headers = request.getHeaders(); if (headers != null && !StringUtils.isEmpty(headers.get(HttpConstants.HttpHeaders.SESSION_TOKEN))) { return; // User is explicitly controlling the session. } String requestConsistency = request.getHeaders().get(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL); boolean sessionConsistency = this.consistencyLevel == ConsistencyLevel.Session || (!StringUtils.isEmpty(requestConsistency) && StringUtils.equalsIgnoreCase(requestConsistency, ConsistencyLevel.Session.toString())); if (!sessionConsistency) { return; // Only apply the session token in case of session consistency } // Apply the ambient session. if (!StringUtils.isEmpty(request.getResourceAddress())) { String sessionToken = this.sessionContainer.resolveGlobalSessionToken(request); if (!StringUtils.isEmpty(sessionToken)) { headers.put(HttpConstants.HttpHeaders.SESSION_TOKEN, sessionToken); } } }