forked from facebook/flipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infrastructure for stream interceptor transform nodes
Summary: Added stream interecptor which gets a chance to augment the messages off the wire. Stream interceptor transformations are async and can fail due to network errors so added error state with a retry button. The retry button will just call the function again. I am also handling errors better generally when this method fails unexpectedly, logging more clearly what went wrong and communicating it to the user Did some refactoring of subtree update event to support this Reviewed By: lblasa Differential Revision: D44415260 fbshipit-source-id: a5a5542b318775b641d53941808399a8fa4634d3
- Loading branch information
1 parent
6b7c529
commit fd673d0
Showing
5 changed files
with
170 additions
and
26 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
desktop/plugins/public/ui-debugger/components/StreamInterceptorErrorView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
import {Button, Result} from 'antd'; | ||
import * as React from 'react'; | ||
|
||
export function StreamInterceptorErrorView({ | ||
retryCallback, | ||
title, | ||
message, | ||
}: { | ||
title: string; | ||
message: string; | ||
retryCallback?: () => void; | ||
}): React.ReactElement { | ||
return ( | ||
<Result | ||
status="error" | ||
title={title} | ||
subTitle={message} | ||
extra={ | ||
retryCallback && ( | ||
<Button onClick={retryCallback} type="primary"> | ||
Retry | ||
</Button> | ||
) | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
desktop/plugins/public/ui-debugger/fb-stubs/StreamInterceptor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
import {Id, Metadata, StreamInterceptor, UINode} from '../types'; | ||
|
||
export function getStreamInterceptor(): StreamInterceptor { | ||
return new NoOpStreamInterceptor(); | ||
} | ||
|
||
class NoOpStreamInterceptor implements StreamInterceptor { | ||
init() { | ||
return null; | ||
} | ||
|
||
async transformNodes(nodes: Map<Id, UINode>): Promise<Map<Id, UINode>> { | ||
return nodes; | ||
} | ||
|
||
async transformMetadata(metadata: Metadata): Promise<Metadata> { | ||
return metadata; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters