Skip to content

Commit c754af0

Browse files
committed
feat: add active passive mechanism
1 parent 72247bd commit c754af0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

shopping-ui/src/services/ProductService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import useAsync from '../utils/useAsync';
66

77
axios.defaults.timeout = 3000;
88

9-
export type Version = 'simple' | 'timeout' | 'exception' | 'parallel' | 'circuitBreaker' | 'retry';
9+
export type Version = 'simple' | 'timeout' | 'exception' | 'parallel' | 'circuitBreaker' | 'retry' | 'fallback';
1010

1111
export function useProducts(version: Version) {
1212
const [timestamp, setTimestamp] = React.useState(new Date());
@@ -20,6 +20,8 @@ export function useProducts(version: Version) {
2020
return ProductService.parallel.fetch();
2121
case 'circuitBreaker':
2222
return ProductService.circuitBreaker.fetch();
23+
case 'fallback':
24+
return ProductService.fallback.fetch();
2325
case 'retry':
2426
return ProductService.retry.fetch();
2527
default:
@@ -65,6 +67,11 @@ export const ProductService = {
6567
return (await axios.get('/products/circuitbreaker')).data;
6668
},
6769
},
70+
fallback: {
71+
async fetch(): Promise<Products> {
72+
return (await axios.get('/products/fallback')).data;
73+
},
74+
},
6875
retry: {
6976
async fetch(): Promise<Products> {
7077
return (await axios.get('/products/retry')).data;

0 commit comments

Comments
 (0)