Skip to content
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

auto init apiClient and support handle error globally #757

Merged
merged 22 commits into from
Sep 22, 2020

Conversation

baurine
Copy link
Collaborator

@baurine baurine commented Sep 14, 2020

resolve #738

What did:

  • Auto init API client
  • Add the mechanism to enable the API request to choose to handle the error by itself or globally, default is global

An example:

企业微信20200915031951

@baurine baurine marked this pull request as draft September 14, 2020 03:36
@baurine baurine marked this pull request as ready for review September 14, 2020 09:08
@baurine baurine requested a review from breezewish September 14, 2020 09:08
@baurine baurine changed the title auto init apiClient auto init apiClient and support handle error globally Sep 14, 2020
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

ui/lib/client/index.tsx Outdated Show resolved Hide resolved
ui/lib/client/index.tsx Outdated Show resolved Hide resolved
ui/lib/client/index.tsx Outdated Show resolved Hide resolved
ui/lib/client/index.tsx Show resolved Hide resolved
ui/lib/client/index.tsx Outdated Show resolved Hide resolved
@baurine baurine marked this pull request as draft September 15, 2020 06:26
@baurine baurine marked this pull request as ready for review September 15, 2020 07:24
@baurine
Copy link
Collaborator Author

baurine commented Sep 15, 2020

Hi @breeswish , addressed the comments, PTAL, thanks!

@breezewish
Copy link
Member

How about omitting errorStrategy: ErrorStrategy.Custom for all useClientRequests, since errors are already extracted to an object field called error? There might be very little cases for GET requests that want some Modal / Message instead of an Error bar

@baurine
Copy link
Collaborator Author

baurine commented Sep 17, 2020

How about omitting errorStrategy: ErrorStrategy.Custom for all useClientRequests, since errors are already extracted to an object field called error? There might be very little cases for GET requests that want some Modal / Message instead of an Error bar

So it means we should always pass errorStrategy: ErrorStrategy.Custom to request inside the useClientRequest, right? like this:

      const reqConfig: ReqConfig = {
        cancelToken: cancelTokenSource.current.token,
        errorStrategy: ErrorStrategy.Custom,
      }
      const resp = await reqFactory(reqConfig)

I count all the references for useClientRequest, now there are 15 references that don't handle the error by itself, so now if they meet error, it will display the error by notification. The other 9 references handle the error by its self, show error by ErrorBar or Alert.

Should we change all the useClientRequest to handle error by itself?

By the way, we should tidy all the cases how they handle the error by this chance.

@baurine baurine force-pushed the auto-init-api-client branch from 27515ce to f2fb98f Compare September 17, 2020 09:50
@breezewish
Copy link
Member

breezewish commented Sep 17, 2020

@baurine Yes, exactly. For your referenced these 15 useClientRequests maybe an error bar is a better place, to be unified with the rest (just a guess. worse to be analyzed case by case). For example, for an InstanceSelect, the error bar can be displayed inside the drop content, instead of just prompting a message. Prompting a message is not helpful for user to know where the error comes from.

We'd better to change all useClientRequest caller to handle the error returned by useClientRequest, i.e. finding some suitable place to reflect the error.

@baurine
Copy link
Collaborator Author

baurine commented Sep 18, 2020

@baurine Yes, exactly. For your referenced these 15 useClientRequests maybe an error bar is a better place, to be unified with the rest (just a guess. worse to be analyzed case by case). For example, for an InstanceSelect, the error bar can be displayed inside the drop content, instead of just prompting a message. Prompting a message is not helpful for user to know where the error comes from.

We'd better to change all useClientRequest caller to handle the error returned by useClientRequest, i.e. finding some suitable place to reflect the error.

Ok, Got it!

@baurine baurine force-pushed the auto-init-api-client branch from c610ac0 to 179d1d0 Compare September 18, 2020 07:33
@baurine
Copy link
Collaborator Author

baurine commented Sep 18, 2020

Tidy all the API requests.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, mostly LGTM

ui/lib/apps/InstanceProfiling/pages/List.tsx Outdated Show resolved Hide resolved
ui/lib/apps/Overview/components/MonitorAlert.tsx Outdated Show resolved Hide resolved
ui/lib/apps/QueryEditor/index.tsx Outdated Show resolved Hide resolved
ui/lib/apps/SearchLogs/components/SearchHeader.tsx Outdated Show resolved Hide resolved
ui/lib/client/index.tsx Show resolved Hide resolved
ui/lib/client/index.tsx Outdated Show resolved Hide resolved
@baurine baurine marked this pull request as draft September 22, 2020 05:57
@baurine
Copy link
Collaborator Author

baurine commented Sep 22, 2020

All kinds of errors:

  • GET:

get_custom_1
get_custom_2
get_custom_3
get_custom_4
get_custom_5

  • POST:

post_custom_1

@baurine baurine marked this pull request as ready for review September 22, 2020 06:52
@baurine
Copy link
Collaborator Author

baurine commented Sep 22, 2020

All addressed, @breeswish , PTAL, thanks!

@breezewish breezewish merged commit 97b76bd into pingcap:master Sep 22, 2020
@baurine baurine deleted the auto-init-api-client branch September 22, 2020 15:03
breezewish pushed a commit that referenced this pull request Nov 26, 2020
breezewish added a commit that referenced this pull request Nov 26, 2020
* misc: Increase ulimit to 65535 for test env (#756)
* test: Fix frontend CI (#752)
* ui: fix dayjs i18n (#755)
* ui: handle error globally (#757)
* statement, slow_query: support all fields in list page (#749)
* ui: memorize expand/collapse full text in detail pages (#775)
* ui: break loop dependencies (#771)
* ui: fix browser compatibility check (#776)
* ui: Refine store location, add zoom and pan (#772)
* ui: show disk usage information for statement and slow query (#777)
* ui: use qps instead of ops (#786)
* statement: support export (#778)
*: Fix slow query and start_ts not working in some cases (#793)
* ui: fix errors doesn't display (#794)
* ui: fix the error message doesn't show correct (#799)
* slow_queries: support export (#792)
* ui: add MySqlFormatter to customize the sql formatter (#805)
*: fix query statement detail error cause by round (#806)
* ui: copy original content instead of formatted content for CopyLink (#802)
* add min height of topology canvas (#804)
* metrics: Support customize Prometheus address (#808)
* clusterinfo: Refine (#815)
* ui: Open statement and slow log in new tab (#816)
* ui: add more time field for slow query detail page (#810)
* slowlog: Improve descriptions (#817)
* build: add action to check release-version is changed for release branch
* Release v2020.11.26.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let API client initialize by default
3 participants