mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-08-24 14:48:42 +08:00
Fetch redis info from RedisInfoView
This commit is contained in:
43
ui/src/actions/redisInfoActions.ts
Normal file
43
ui/src/actions/redisInfoActions.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Dispatch } from "redux";
|
||||
import { getRedisInfo, RedisInfo } from "../api";
|
||||
|
||||
// List of redis-info related action types.
|
||||
export const GET_REDIS_INFO_BEGIN = "GET_REDIS_INFO_BEGIN";
|
||||
export const GET_REDIS_INFO_SUCCESS = "GET_REDIS_INFO_SUCCESS";
|
||||
export const GET_REDIS_INFO_ERROR = "GET_REDIS_INFO_ERROR";
|
||||
|
||||
interface GetRedisInfoBeginAction {
|
||||
type: typeof GET_REDIS_INFO_BEGIN;
|
||||
}
|
||||
|
||||
interface GetRedisInfoSuccessAction {
|
||||
type: typeof GET_REDIS_INFO_SUCCESS;
|
||||
payload: RedisInfo;
|
||||
}
|
||||
|
||||
interface GetRedisInfoErrorAction {
|
||||
type: typeof GET_REDIS_INFO_ERROR;
|
||||
error: string;
|
||||
}
|
||||
|
||||
// Union of all redis-info related actions.
|
||||
export type RedisInfoActionTypes =
|
||||
| GetRedisInfoBeginAction
|
||||
| GetRedisInfoErrorAction
|
||||
| GetRedisInfoSuccessAction;
|
||||
|
||||
export function getRedisInfoAsync() {
|
||||
return async (dispatch: Dispatch<RedisInfoActionTypes>) => {
|
||||
dispatch({ type: GET_REDIS_INFO_BEGIN });
|
||||
try {
|
||||
const response = await getRedisInfo();
|
||||
dispatch({ type: GET_REDIS_INFO_SUCCESS, payload: response });
|
||||
} catch (error) {
|
||||
console.error("getRedisInfoAsync: ", error);
|
||||
dispatch({
|
||||
type: GET_REDIS_INFO_BEGIN,
|
||||
error: "Could not fetch redis info",
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user