clintropolis commented on a change in pull request #8805: Web console: fine 
grained capabilities / graceful degradation
URL: https://github.com/apache/incubator-druid/pull/8805#discussion_r342949872
 
 

 ##########
 File path: 
web-console/src/views/home-view/datasources-card/datasources-card.tsx
 ##########
 @@ -50,14 +50,17 @@ export class DatasourcesCard extends React.PureComponent<
     this.datasourceQueryManager = new QueryManager({
       processQuery: async capabilities => {
         let datasources: string[];
-        if (capabilities !== 'no-sql') {
+        if (capabilities.hasSql()) {
           datasources = await queryDruidSql({
             query: `SELECT datasource FROM sys.segments GROUP BY 1`,
           });
-        } else {
+        } else if (capabilities.hasCoordinatorAccess()) {
           const datasourcesResp = await 
axios.get('/druid/coordinator/v1/datasources');
           datasources = datasourcesResp.data;
+        } else {
+          throw new Error(`must have SQL or coordinator access`);
 
 Review comment:
   I see a handful of these similar themed errors, would it make sense to make 
some custom errors like `NoCoordinatorError`, `NoOverlordError`, etc so you 
don't have to repeat the string message?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to