mirror of
https://github.com/apache/superset.git
synced 2026-04-17 15:15:20 +00:00
[domain sharding] Freeup main domain when domain sharding is enabled (#9060)
* [domain sharding] Freeup main domain when domain sharding is enabled * add change per comment + extra cleanup
This commit is contained in:
@@ -163,13 +163,8 @@ describe('exploreUtils', () => {
|
||||
endpointType: 'json',
|
||||
allowDomainSharding: true,
|
||||
}).url;
|
||||
expect(url).toMatch(availableDomains[0]);
|
||||
|
||||
url = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
allowDomainSharding: true,
|
||||
}).url;
|
||||
// skip main domain for fetching chart if domain sharding is enabled
|
||||
// to leave main domain free for other calls like fav star, save change, etc.
|
||||
expect(url).toMatch(availableDomains[1]);
|
||||
|
||||
url = getExploreUrlAndPayload({
|
||||
@@ -192,7 +187,7 @@ describe('exploreUtils', () => {
|
||||
endpointType: 'json',
|
||||
allowDomainSharding: true,
|
||||
}).url;
|
||||
expect(url).toMatch(availableDomains[0]);
|
||||
expect(url).toMatch(availableDomains[1]);
|
||||
});
|
||||
it('not generate url to different domains without flag', () => {
|
||||
let csvURL = getExploreUrlAndPayload({
|
||||
|
||||
@@ -33,7 +33,7 @@ import { addDangerToast } from '../messageToasts/actions';
|
||||
import { logEvent } from '../logger/actions';
|
||||
import { Logger, LOG_ACTIONS_LOAD_CHART } from '../logger/LogUtils';
|
||||
import getClientErrorObject from '../utils/getClientErrorObject';
|
||||
import { allowCrossDomain } from '../utils/hostNamesConfig';
|
||||
import { allowCrossDomain as allowDomainSharding } from '../utils/hostNamesConfig';
|
||||
|
||||
export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED';
|
||||
export function chartUpdateStarted(queryController, latestQueryFormData, key) {
|
||||
@@ -212,7 +212,7 @@ export function exploreJSON(
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force,
|
||||
allowDomainSharding: true,
|
||||
allowDomainSharding,
|
||||
method,
|
||||
});
|
||||
const logStart = Logger.getTimestamp();
|
||||
@@ -227,7 +227,7 @@ export function exploreJSON(
|
||||
signal,
|
||||
timeout: timeout * 1000,
|
||||
};
|
||||
if (allowCrossDomain) {
|
||||
if (allowDomainSharding) {
|
||||
querySettings = {
|
||||
...querySettings,
|
||||
mode: 'cors',
|
||||
|
||||
@@ -34,6 +34,14 @@ function getHostName(allowDomainSharding = false) {
|
||||
if (allowDomainSharding) {
|
||||
currentIndex = requestCounter % availableDomains.length;
|
||||
requestCounter += 1;
|
||||
|
||||
// if domain sharding is enabled, skip main domain for fetching chart API
|
||||
// leave main domain free for other calls like fav star, save change, etc.
|
||||
// to make dashboard be responsive when it's loading large number of charts
|
||||
if (currentIndex === 0) {
|
||||
currentIndex += 1;
|
||||
requestCounter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return availableDomains[currentIndex];
|
||||
|
||||
Reference in New Issue
Block a user