You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/09/18 13:44:58 UTC

[GitHub] [druid] AshishKapoor opened a new pull request #10408: Web console: single instance of axios for all network requests

AshishKapoor opened a new pull request #10408:
URL: https://github.com/apache/druid/pull/10408


   <!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
   
   Fixes #10402. As proposed.
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for committers:
   https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
   
   ### Description
   Make use of a single instance of axios for all network requests.
   <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the problem? -->
   
   <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: -->
   
   ### Makes it easy to configure network calls with axios
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   <hr>
   
   This PR has:
   - [x] been self-reviewed.
   - [x] been tested in a test Druid cluster.
   
   <hr>
   
   ##### Key changed/added classes in this PR
   - All axios imports
   
   Sincerely
   Ashish Kapoor


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r491724970



##########
File path: web-console/src/entry.ts
##########
@@ -70,14 +70,14 @@ if (typeof consoleConfig.title === 'string') {
 }
 
 if (consoleConfig.baseURL) {
-  axios.defaults.baseURL = consoleConfig.baseURL;
+  Api.defaults.baseURL = consoleConfig.baseURL;

Review comment:
       These will now be ignored




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] ccaominh commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
ccaominh commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-697820571


   > > > This PR currently breaks the existing configuration route.
   > > > Try adding `"customHeaders": { 'x-test-header': 'this-is-a-test' }` to the console-config.js file and see that the custom headers will not be applied. This is because while you are creating a custom instance you are still setting `Api.defaults` which will not be read now.
   > > > I suggest you make a method called `Api.initialize` that will take the configs and create the instance. It must be called before any API requests can go through (in `entry.ts`).
   > > 
   > > 
   > > Is it possible to add a test so that CI can help ensure this doesn't break in the future?
   > 
   > @ccaominh maybe we can re-run the failed travis-cI test case. Please let me know how I can get it fixed.
   
   I've retriggered ` (Compile=openjdk8, Run=openjdk8) compaction integration test ` since the failure doesn't look related to this PR.
   
   I think it'd be useful to add a web console test that ensures that the custom header, etc. are preserved.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696402795


   *@vogievetsky* Fixed the issue and created an initialize method. Please let
   me know how we can make it better.
   
   On Mon, Sep 21, 2020 at 12:59 AM Vadim Ogievetsky <no...@github.com>
   wrote:
   
   > *@vogievetsky* requested changes on this pull request.
   >
   > This PR currently breaks the existing configuration route.
   > Try adding "customHeaders": { 'x-test-header': 'this-is-a-test' } to the
   > console-config.js file and see that the custom headers will not be applied.
   > This is because while you are creating a custom instance you are still
   > setting Api.defaults which will not be read now.
   >
   > I suggest you make a method called Api.initialize that will take the
   > configs and create the instance. It must be called before any API requests
   > can go through (in entry.ts).
   > ------------------------------
   >
   > In web-console/src/entry.ts
   > <https://github.com/apache/druid/pull/10408#discussion_r491724970>:
   >
   > > @@ -70,14 +70,14 @@ if (typeof consoleConfig.title === 'string') {
   >  }
   >
   >  if (consoleConfig.baseURL) {
   > -  axios.defaults.baseURL = consoleConfig.baseURL;
   > +  Api.defaults.baseURL = consoleConfig.baseURL;
   >
   > These will now be ignored
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/druid/pull/10408#pullrequestreview-492216965>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/ABHWJIYP624GA2XUOSCN2TTSGZJYVANCNFSM4RSAOROQ>
   > .
   >
   
   
   -- 
   Sincerely
   Ashish Kapoor
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] ccaominh commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
ccaominh commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696405034


   > This PR currently breaks the existing configuration route.
   > Try adding `"customHeaders": { 'x-test-header': 'this-is-a-test' }` to the console-config.js file and see that the custom headers will not be applied. This is because while you are creating a custom instance you are still setting `Api.defaults` which will not be read now.
   > 
   > I suggest you make a method called `Api.initialize` that will take the configs and create the instance. It must be called before any API requests can go through (in `entry.ts`).
   
   Is it possible to add a test so that CI can help ensure this doesn't break in the future?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r502765494



##########
File path: web-console/src/singletons/api.ts
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import axios from 'axios';
+
+export const API_ENDPOINTS = {
+  status: '/status',
+  properties: '/status/properties',
+  supervisor: '/druid/indexer/v1/supervisor',
+  supervisorFull: '/druid/indexer/v1/supervisor?full',
+  supervisorResumeAll: '/druid/indexer/v1/supervisor/resumeAll',
+  supervisorSuspendAll: '/druid/indexer/v1/supervisor/suspendAll',
+  supervisorTerminateAll: '/druid/indexer/v1/supervisor/terminateAll',
+  task: '/druid/indexer/v1/task',
+  tasks: '/druid/indexer/v1/tasks',
+  worker: '/druid/indexer/v1/worker',
+  workers: '/druid/indexer/v1/workers',
+  datasources: '/druid/coordinator/v1/datasources',
+  datasourcesSimple: '/druid/coordinator/v1/datasources?simple',
+  overlordStatus: '/proxy/overlord/status',
+  overlordStatusProperties: '/proxy/overlord/status/properties',
+  coordinatorStatus: '/proxy/coordinator/status',
+  coordinatorStatusProperties: '/proxy/coordinator/status/properties',
+  coordinatorCompactionCompact: '/druid/coordinator/v1/compaction/compact',
+  coordinatorRules: '/druid/coordinator/v1/rules',
+  coordinatorLookupsConfig: '/druid/coordinator/v1/lookups/config',
+  coordinatorLookupsConfigDiscover: '/druid/coordinator/v1/lookups/config?discover=true',
+  coordinatorLookupsConfigAll: '/druid/coordinator/v1/lookups/config/all',
+  coordinatorConfig: '/druid/coordinator/v1/config',
+  coordinatorConfigCompaction: '/druid/coordinator/v1/config/compaction',
+  coordinatorLoadStatusSimple: '/druid/coordinator/v1/loadstatus?simple',
+  coordinatorMetadataDatasources: '/druid/coordinator/v1/metadata/datasources',
+  coordinatorMetadataDatasourcesIncludeDisabled:
+    '/druid/coordinator/v1/metadata/datasources?includeDisabled',
+  coordinatorCompactionStatus: '/druid/coordinator/v1/compaction/status',
+  coordinatorTiers: '/druid/coordinator/v1/tiers',
+  coordinatorLookupsStatus: '/druid/coordinator/v1/lookups/status',
+  coordinatorServersSimple: '/druid/coordinator/v1/servers?simple',
+  coordinatorLoadqueueSimple: '/druid/coordinator/v1/loadqueue?simple',
+  druidV2: '/druid/v2',
+  druidV2Sql: '/druid/v2/sql',
+};

Review comment:
       @vogievetsky we can add all the dynamic endpoints later.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor closed pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor closed pull request #10408:
URL: https://github.com/apache/druid/pull/10408


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r502764568



##########
File path: web-console/src/singletons/api.ts
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import axios from 'axios';
+
+export const API_ENDPOINTS = {
+  status: '/status',
+  properties: '/status/properties',
+  supervisor: '/druid/indexer/v1/supervisor',
+  supervisorFull: '/druid/indexer/v1/supervisor?full',
+  supervisorResumeAll: '/druid/indexer/v1/supervisor/resumeAll',
+  supervisorSuspendAll: '/druid/indexer/v1/supervisor/suspendAll',
+  supervisorTerminateAll: '/druid/indexer/v1/supervisor/terminateAll',
+  task: '/druid/indexer/v1/task',
+  tasks: '/druid/indexer/v1/tasks',
+  worker: '/druid/indexer/v1/worker',
+  workers: '/druid/indexer/v1/workers',
+  datasources: '/druid/coordinator/v1/datasources',
+  datasourcesSimple: '/druid/coordinator/v1/datasources?simple',
+  overlordStatus: '/proxy/overlord/status',
+  overlordStatusProperties: '/proxy/overlord/status/properties',
+  coordinatorStatus: '/proxy/coordinator/status',
+  coordinatorStatusProperties: '/proxy/coordinator/status/properties',
+  coordinatorCompactionCompact: '/druid/coordinator/v1/compaction/compact',
+  coordinatorRules: '/druid/coordinator/v1/rules',
+  coordinatorLookupsConfig: '/druid/coordinator/v1/lookups/config',
+  coordinatorLookupsConfigDiscover: '/druid/coordinator/v1/lookups/config?discover=true',
+  coordinatorLookupsConfigAll: '/druid/coordinator/v1/lookups/config/all',
+  coordinatorconfig: '/druid/coordinator/v1/config',
+  coordinatorConfigCompaction: '/druid/coordinator/v1/config/compaction',
+  coordinatorLoadStatusSimple: '/druid/coordinator/v1/loadstatus?simple',
+  coordinatorMetadataDatasources: '/druid/coordinator/v1/metadata/datasources',
+  coordinatorMetadataDatasourcesIncludeDisabled:
+    '/druid/coordinator/v1/metadata/datasources?includeDisabled',
+  coordinatorCompactionStatus: '/druid/coordinator/v1/compaction/status',
+  coordinatorTiers: '/druid/coordinator/v1/tiers',
+  coordinatorLookupsStatus: '/druid/coordinator/v1/lookups/status',
+  coordinatorServersSimple: '/druid/coordinator/v1/servers?simple',
+  coordinatorLoadqueueSimple: '/druid/coordinator/v1/loadqueue?simple',
+  druidV2: '/druid/v2',
+  druidV2Sql: '/druid/v2/sql',

Review comment:
       @vogievetsky we can add all the dynamic endpoints later.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-697484928


   > > This PR currently breaks the existing configuration route.
   > > Try adding `"customHeaders": { 'x-test-header': 'this-is-a-test' }` to the console-config.js file and see that the custom headers will not be applied. This is because while you are creating a custom instance you are still setting `Api.defaults` which will not be read now.
   > > I suggest you make a method called `Api.initialize` that will take the configs and create the instance. It must be called before any API requests can go through (in `entry.ts`).
   > 
   > Is it possible to add a test so that CI can help ensure this doesn't break in the future?
   
   @ccaominh maybe we can re-run the failed travis-cI test case. Please let me know how I can get it fixed.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r502988225



##########
File path: web-console/src/views/datasource-view/datasource-view.tsx
##########
@@ -425,7 +425,7 @@ GROUP BY 1`;
     return (
       <AsyncActionDialog
         action={async () => {
-          const resp = await axios.delete(
+          const resp = await Api.delete(
             `/druid/coordinator/v1/datasources/${datasourceToMarkAsUnusedAllSegmentsIn}`,

Review comment:
       In the theme of listing all the API endpoints in once file, I think this one could be extracted also for consistency. Maybe extract it as `/druid/coordinator/v1/datasources/%s` and then do a `.replace('%s', datasourceToMarkAsUnusedAllSegmentsIn)` in this function?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r493926587



##########
File path: web-console/src/singletons/api.ts
##########
@@ -18,4 +18,9 @@
 
 import axios from 'axios';
 
-export const Api = axios.create();
+function initialize() {

Review comment:
       I meant that instead of setting `axios.defaults` (above) you can pass the instance cnfiguration to the initialize method. So the initialize method would take `{ baseURL, headers }` etc as an argument. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696402795


   *@vogievetsky* Fixed the issue and created an initialize method. Please let
   me know how we can make it better.
   
   On Mon, Sep 21, 2020 at 12:59 AM Vadim Ogievetsky <no...@github.com>
   wrote:
   
   > *@vogievetsky* requested changes on this pull request.
   >
   > This PR currently breaks the existing configuration route.
   > Try adding "customHeaders": { 'x-test-header': 'this-is-a-test' } to the
   > console-config.js file and see that the custom headers will not be applied.
   > This is because while you are creating a custom instance you are still
   > setting Api.defaults which will not be read now.
   >
   > I suggest you make a method called Api.initialize that will take the
   > configs and create the instance. It must be called before any API requests
   > can go through (in entry.ts).
   > ------------------------------
   >
   > In web-console/src/entry.ts
   > <https://github.com/apache/druid/pull/10408#discussion_r491724970>:
   >
   > > @@ -70,14 +70,14 @@ if (typeof consoleConfig.title === 'string') {
   >  }
   >
   >  if (consoleConfig.baseURL) {
   > -  axios.defaults.baseURL = consoleConfig.baseURL;
   > +  Api.defaults.baseURL = consoleConfig.baseURL;
   >
   > These will now be ignored
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/druid/pull/10408#pullrequestreview-492216965>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/ABHWJIYP624GA2XUOSCN2TTSGZJYVANCNFSM4RSAOROQ>
   > .
   >
   
   
   -- 
   Sincerely
   Ashish Kapoor
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] ccaominh commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
ccaominh commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696405034


   > This PR currently breaks the existing configuration route.
   > Try adding `"customHeaders": { 'x-test-header': 'this-is-a-test' }` to the console-config.js file and see that the custom headers will not be applied. This is because while you are creating a custom instance you are still setting `Api.defaults` which will not be read now.
   > 
   > I suggest you make a method called `Api.initialize` that will take the configs and create the instance. It must be called before any API requests can go through (in `entry.ts`).
   
   Is it possible to add a test so that CI can help ensure this doesn't break in the future?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-695033422


   > Is the idea of this to migrate the instance configuration from the defaults ( https://github.com/apache/druid/blob/master/web-console/src/entry.ts#L72 ) to this singleton Api file?
   
   @vogievetsky Yes, you are correct! 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r503111412



##########
File path: web-console/src/views/datasource-view/datasource-view.tsx
##########
@@ -425,7 +425,7 @@ GROUP BY 1`;
     return (
       <AsyncActionDialog
         action={async () => {
-          const resp = await axios.delete(
+          const resp = await Api.delete(
             `/druid/coordinator/v1/datasources/${datasourceToMarkAsUnusedAllSegmentsIn}`,

Review comment:
       Done for all the remaining ones.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] ccaominh commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
ccaominh commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696405034


   > This PR currently breaks the existing configuration route.
   > Try adding `"customHeaders": { 'x-test-header': 'this-is-a-test' }` to the console-config.js file and see that the custom headers will not be applied. This is because while you are creating a custom instance you are still setting `Api.defaults` which will not be read now.
   > 
   > I suggest you make a method called `Api.initialize` that will take the configs and create the instance. It must be called before any API requests can go through (in `entry.ts`).
   
   Is it possible to add a test so that CI can help ensure this doesn't break in the future?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r503065771



##########
File path: web-console/src/views/datasource-view/datasource-view.tsx
##########
@@ -425,7 +425,7 @@ GROUP BY 1`;
     return (
       <AsyncActionDialog
         action={async () => {
-          const resp = await axios.delete(
+          const resp = await Api.delete(
             `/druid/coordinator/v1/datasources/${datasourceToMarkAsUnusedAllSegmentsIn}`,

Review comment:
       How about this?
   ```
   `${API_ENDPOINTS.datasources}/${datasourceToMarkAsUnusedAllSegmentsIn}`,
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-696402795


   *@vogievetsky* Fixed the issue and created an initialize method. Please let
   me know how we can make it better.
   
   On Mon, Sep 21, 2020 at 12:59 AM Vadim Ogievetsky <no...@github.com>
   wrote:
   
   > *@vogievetsky* requested changes on this pull request.
   >
   > This PR currently breaks the existing configuration route.
   > Try adding "customHeaders": { 'x-test-header': 'this-is-a-test' } to the
   > console-config.js file and see that the custom headers will not be applied.
   > This is because while you are creating a custom instance you are still
   > setting Api.defaults which will not be read now.
   >
   > I suggest you make a method called Api.initialize that will take the
   > configs and create the instance. It must be called before any API requests
   > can go through (in entry.ts).
   > ------------------------------
   >
   > In web-console/src/entry.ts
   > <https://github.com/apache/druid/pull/10408#discussion_r491724970>:
   >
   > > @@ -70,14 +70,14 @@ if (typeof consoleConfig.title === 'string') {
   >  }
   >
   >  if (consoleConfig.baseURL) {
   > -  axios.defaults.baseURL = consoleConfig.baseURL;
   > +  Api.defaults.baseURL = consoleConfig.baseURL;
   >
   > These will now be ignored
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/druid/pull/10408#pullrequestreview-492216965>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/ABHWJIYP624GA2XUOSCN2TTSGZJYVANCNFSM4RSAOROQ>
   > .
   >
   
   
   -- 
   Sincerely
   Ashish Kapoor
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor edited a comment on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor edited a comment on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-695033422


   > Is the idea of this to migrate the instance configuration from the defaults ( https://github.com/apache/druid/blob/master/web-console/src/entry.ts#L72 ) to this singleton Api file?
   
   @vogievetsky Yes, you are correct!
   
   One place to configure axios for the network requests and services. This way we can further define and separate all the network requests out of the views (in future).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r503111412



##########
File path: web-console/src/views/datasource-view/datasource-view.tsx
##########
@@ -425,7 +425,7 @@ GROUP BY 1`;
     return (
       <AsyncActionDialog
         action={async () => {
-          const resp = await axios.delete(
+          const resp = await Api.delete(
             `/druid/coordinator/v1/datasources/${datasourceToMarkAsUnusedAllSegmentsIn}`,

Review comment:
       Hey @vogievetsky 
   
   done for all the remaining ones.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] AshishKapoor commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
AshishKapoor commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r502764568



##########
File path: web-console/src/singletons/api.ts
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import axios from 'axios';
+
+export const API_ENDPOINTS = {
+  status: '/status',
+  properties: '/status/properties',
+  supervisor: '/druid/indexer/v1/supervisor',
+  supervisorFull: '/druid/indexer/v1/supervisor?full',
+  supervisorResumeAll: '/druid/indexer/v1/supervisor/resumeAll',
+  supervisorSuspendAll: '/druid/indexer/v1/supervisor/suspendAll',
+  supervisorTerminateAll: '/druid/indexer/v1/supervisor/terminateAll',
+  task: '/druid/indexer/v1/task',
+  tasks: '/druid/indexer/v1/tasks',
+  worker: '/druid/indexer/v1/worker',
+  workers: '/druid/indexer/v1/workers',
+  datasources: '/druid/coordinator/v1/datasources',
+  datasourcesSimple: '/druid/coordinator/v1/datasources?simple',
+  overlordStatus: '/proxy/overlord/status',
+  overlordStatusProperties: '/proxy/overlord/status/properties',
+  coordinatorStatus: '/proxy/coordinator/status',
+  coordinatorStatusProperties: '/proxy/coordinator/status/properties',
+  coordinatorCompactionCompact: '/druid/coordinator/v1/compaction/compact',
+  coordinatorRules: '/druid/coordinator/v1/rules',
+  coordinatorLookupsConfig: '/druid/coordinator/v1/lookups/config',
+  coordinatorLookupsConfigDiscover: '/druid/coordinator/v1/lookups/config?discover=true',
+  coordinatorLookupsConfigAll: '/druid/coordinator/v1/lookups/config/all',
+  coordinatorconfig: '/druid/coordinator/v1/config',
+  coordinatorConfigCompaction: '/druid/coordinator/v1/config/compaction',
+  coordinatorLoadStatusSimple: '/druid/coordinator/v1/loadstatus?simple',
+  coordinatorMetadataDatasources: '/druid/coordinator/v1/metadata/datasources',
+  coordinatorMetadataDatasourcesIncludeDisabled:
+    '/druid/coordinator/v1/metadata/datasources?includeDisabled',
+  coordinatorCompactionStatus: '/druid/coordinator/v1/compaction/status',
+  coordinatorTiers: '/druid/coordinator/v1/tiers',
+  coordinatorLookupsStatus: '/druid/coordinator/v1/lookups/status',
+  coordinatorServersSimple: '/druid/coordinator/v1/servers?simple',
+  coordinatorLoadqueueSimple: '/druid/coordinator/v1/loadqueue?simple',
+  druidV2: '/druid/v2',
+  druidV2Sql: '/druid/v2/sql',

Review comment:
       @vogievetsky we can add all the dynamic endpoints later.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] lgtm-com[bot] commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-732207836


   This pull request **introduces 1 alert** when merging db2e46b515eb48735f955410420caad86f50d622 into 4537016cad4e17786b81e74b0e99013838afe788 - [view on LGTM.com](https://lgtm.com/projects/g/apache/druid/rev/pr-d0ba8a6c80f4b173a3b07cab39f32015d1d822da)
   
   **new alerts:**
   
   * 1 for Unused variable, import, function or class


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on pull request #10408:
URL: https://github.com/apache/druid/pull/10408#issuecomment-695000992


   Isn't the current usage of Axios already using a single (global) instance? As defined here: https://github.com/axios/axios/blob/master/lib/axios.js#L29
   
   Is the idea of this to migrate the instance configuration from the defaults ( https://github.com/apache/druid/blob/master/web-console/src/entry.ts#L72 ) to this singleton Api file?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] vogievetsky commented on a change in pull request #10408: Web console: single instance of axios for all network requests

Posted by GitBox <gi...@apache.org>.
vogievetsky commented on a change in pull request #10408:
URL: https://github.com/apache/druid/pull/10408#discussion_r491724970



##########
File path: web-console/src/entry.ts
##########
@@ -70,14 +70,14 @@ if (typeof consoleConfig.title === 'string') {
 }
 
 if (consoleConfig.baseURL) {
-  axios.defaults.baseURL = consoleConfig.baseURL;
+  Api.defaults.baseURL = consoleConfig.baseURL;

Review comment:
       These will now be ignored




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org