mirror of https://github.com/longtai-cn/hippo4j
Feat oe thread pool (#1468)
* feat: thread pool * feat: remove yarnloack --------- Co-authored-by: yikai <yikai@didiglobal.com>pull/1472/head
parent
ac3cb9ab3d
commit
35cf5d82d0
@ -0,0 +1,20 @@
|
||||
export enum STR_MAP {
|
||||
DYNAMIC_THREAD_POOL = 'dynamicThreadPool',
|
||||
THREAD_POOL_MANAGE = 'threadPoolManage',
|
||||
PROJECT = 'project',
|
||||
SEARCH = 'search',
|
||||
ADD = 'add',
|
||||
SERIAL_NUMBER = 'serialNumber',
|
||||
TENANTRY = 'tenantry',
|
||||
THREAD_POOL = 'threadPool',
|
||||
CORE_THREAD = 'coreThread',
|
||||
MAXIMUM_THREAD = 'maximumThread',
|
||||
QUEUE_TYPE = 'queueType',
|
||||
QUEUE_CAPACITY = 'queueCapacity',
|
||||
REJECTION_STRATEGY = 'rejectionStrategy',
|
||||
EXECUTION_TIMEOUT = 'executionTimeout',
|
||||
ALARM_OR_NOT = 'alarmOrNot',
|
||||
CREATION_TIME = 'creationTime',
|
||||
UPDATE_TIME = 'update time',
|
||||
EDIT = 'edit',
|
||||
}
|
@ -1,5 +1,24 @@
|
||||
import { STR_MAP } from './constants';
|
||||
|
||||
const enTranslationMap: { [key: string]: string } = {
|
||||
hello: 'hello',
|
||||
[STR_MAP.DYNAMIC_THREAD_POOL]: 'Dynamic thread pool',
|
||||
[STR_MAP.THREAD_POOL_MANAGE]: 'Thread pool management',
|
||||
[STR_MAP.PROJECT]: 'project',
|
||||
[STR_MAP.SEARCH]: 'search',
|
||||
[STR_MAP.ADD]: 'add',
|
||||
[STR_MAP.SERIAL_NUMBER]: 'number',
|
||||
[STR_MAP.TENANTRY]: 'tenantry',
|
||||
[STR_MAP.THREAD_POOL]: 'thread pool',
|
||||
[STR_MAP.CORE_THREAD]: 'core thread',
|
||||
[STR_MAP.MAXIMUM_THREAD]: 'maximum thread',
|
||||
[STR_MAP.QUEUE_TYPE]: 'queue type',
|
||||
[STR_MAP.QUEUE_CAPACITY]: 'queue capacity',
|
||||
[STR_MAP.REJECTION_STRATEGY]: 'rejection strategy',
|
||||
[STR_MAP.EXECUTION_TIMEOUT]: 'execution timeout',
|
||||
[STR_MAP.ALARM_OR_NOT]: 'alarm or not',
|
||||
[STR_MAP.CREATION_TIME]: 'creation time',
|
||||
[STR_MAP.UPDATE_TIME]: 'update time',
|
||||
[STR_MAP.EDIT]: 'edit',
|
||||
};
|
||||
|
||||
export default enTranslationMap;
|
||||
|
@ -1,5 +1,24 @@
|
||||
import { STR_MAP } from './constants';
|
||||
|
||||
const zhTranslationMap: { [key: string]: string } = {
|
||||
hello: '你好',
|
||||
[STR_MAP.DYNAMIC_THREAD_POOL]: '动态线程池',
|
||||
[STR_MAP.THREAD_POOL_MANAGE]: '线程池管理',
|
||||
[STR_MAP.PROJECT]: '项目',
|
||||
[STR_MAP.SEARCH]: '搜索',
|
||||
[STR_MAP.ADD]: '添加',
|
||||
[STR_MAP.SERIAL_NUMBER]: '序号',
|
||||
[STR_MAP.TENANTRY]: '租户',
|
||||
[STR_MAP.THREAD_POOL]: '线程池',
|
||||
[STR_MAP.CORE_THREAD]: '核心线程',
|
||||
[STR_MAP.MAXIMUM_THREAD]: '最大线程',
|
||||
[STR_MAP.QUEUE_TYPE]: '队列类型',
|
||||
[STR_MAP.QUEUE_CAPACITY]: '队列容量',
|
||||
[STR_MAP.REJECTION_STRATEGY]: '拒绝策略',
|
||||
[STR_MAP.EXECUTION_TIMEOUT]: '执行超时',
|
||||
[STR_MAP.ALARM_OR_NOT]: '是否报警',
|
||||
[STR_MAP.CREATION_TIME]: '创建时间',
|
||||
[STR_MAP.UPDATE_TIME]: '更新时间',
|
||||
[STR_MAP.EDIT]: '操作',
|
||||
};
|
||||
|
||||
export default zhTranslationMap;
|
||||
|
@ -0,0 +1,3 @@
|
||||
export * from './useThemeMode';
|
||||
export * from './useTransLate';
|
||||
export * from './useFormToUrl';
|
@ -0,0 +1,52 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { parse } from 'qs';
|
||||
import useUrlState from '@ahooksjs/use-url-state';
|
||||
import { FormInstance } from 'antd';
|
||||
|
||||
export function useFormStateToUrl<T extends Record<string, any>>(
|
||||
form: FormInstance,
|
||||
params?: T
|
||||
): {
|
||||
urlState: any;
|
||||
isFirstMount: boolean;
|
||||
handleSetUrlState: () => void;
|
||||
} {
|
||||
const [state, setState] = useState<any>();
|
||||
const [urlState, setUrlState] = useUrlState<any>();
|
||||
const [count, setCount] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
const url = window.location.search.split('?')[1] ?? null;
|
||||
const urlParams = parse(url) as T;
|
||||
const result: Partial<T> = {};
|
||||
setState(urlParams);
|
||||
for (const key in params) {
|
||||
if (Object.prototype.hasOwnProperty.call(params, key)) {
|
||||
const paramValue = urlParams[key];
|
||||
if (paramValue ?? false) {
|
||||
if (typeof params[key] === 'number') {
|
||||
const parsedValue = parseFloat(paramValue);
|
||||
if (!isNaN(parsedValue)) {
|
||||
result[key] = parsedValue as T[keyof T];
|
||||
}
|
||||
} else {
|
||||
result[key] = paramValue as T[keyof T];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
form.setFieldsValue(result);
|
||||
setCount(count => count + 1);
|
||||
}, [setState, setCount, form, params]);
|
||||
|
||||
const handleSetUrlState = () => {
|
||||
const values = form.getFieldsValue();
|
||||
setUrlState({ ...state, ...values });
|
||||
};
|
||||
|
||||
const isFirstMount = useMemo(() => {
|
||||
return count === 1;
|
||||
}, [count]);
|
||||
|
||||
return { urlState, isFirstMount, handleSetUrlState };
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const useTran = (str: string): string => {
|
||||
const { t } = useTranslation();
|
||||
return t(str);
|
||||
};
|
@ -0,0 +1,90 @@
|
||||
import { Button, Form, Select, Space, Table, Typography } from 'antd';
|
||||
import { useFormStateToUrl, useTran } from '@/hooks';
|
||||
import { STR_MAP } from '@/config/i18n/locales/constants';
|
||||
import { ColumnProps } from 'antd/es/table';
|
||||
const { Title } = Typography;
|
||||
const { Item } = Form;
|
||||
|
||||
const params = { project: 0, thpool: 0 };
|
||||
const ThreadPoll = () => {
|
||||
const [form] = Form.useForm();
|
||||
const { handleSetUrlState } = useFormStateToUrl<{ project: number; thpool: number }>(form, params);
|
||||
const columns: ColumnProps<any>[] = [
|
||||
{
|
||||
title: useTran(STR_MAP.SERIAL_NUMBER),
|
||||
dataIndex: 'order',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.PROJECT),
|
||||
dataIndex: 'project',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.TENANTRY),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.THREAD_POOL),
|
||||
dataIndex: 'thread_pool',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.MAXIMUM_THREAD),
|
||||
dataIndex: 'maximum_thread',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.QUEUE_TYPE),
|
||||
dataIndex: 'queue_type',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.REJECTION_STRATEGY),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.EXECUTION_TIMEOUT),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.ALARM_OR_NOT),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.CREATION_TIME),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.UPDATE_TIME),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
{
|
||||
title: useTran(STR_MAP.EDIT),
|
||||
dataIndex: 'tenantry',
|
||||
},
|
||||
];
|
||||
|
||||
const handleSubmit = () => {
|
||||
handleSetUrlState();
|
||||
};
|
||||
|
||||
return (
|
||||
<Space direction="vertical" style={{ width: '100%' }} size="large">
|
||||
<Title>{useTran(STR_MAP.THREAD_POOL)}</Title>
|
||||
<Form form={form} layout="inline">
|
||||
<Item name="project" style={{ flex: 1 }}>
|
||||
<Select options={[{ label: '哈哈哈', value: 1 }]} placeholder={useTran(STR_MAP.PROJECT)}></Select>
|
||||
</Item>
|
||||
<Item name="thpool" style={{ flex: 1 }}>
|
||||
<Select options={[{ label: '哈哈哈', value: 1 }]} placeholder={useTran(STR_MAP.PROJECT)}></Select>
|
||||
</Item>
|
||||
<Item style={{ flex: 4 }}>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit" onClick={handleSubmit}>
|
||||
{useTran(STR_MAP.SEARCH)}
|
||||
</Button>
|
||||
<Button type="primary">{useTran(STR_MAP.ADD)}</Button>
|
||||
</Space>
|
||||
</Item>
|
||||
</Form>
|
||||
<Table columns={columns}></Table>
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
export default ThreadPoll;
|
@ -0,0 +1,11 @@
|
||||
import { IRouterList } from '@/typings';
|
||||
import ThreadPoll from '.';
|
||||
|
||||
const routerList: IRouterList[] = [
|
||||
{
|
||||
path: '/thread-poll/index',
|
||||
component: ThreadPoll,
|
||||
},
|
||||
];
|
||||
|
||||
export default routerList;
|
@ -1,7 +1,8 @@
|
||||
import { IRouterList } from '@/typings';
|
||||
import homeRouter from '@/page/home/router';
|
||||
import aboutRouter from '@/page/about/router';
|
||||
import ThreadPoolRouter from '@/page/thread-pool/router';
|
||||
import tenantRouter from '@/page/tenant/router';
|
||||
|
||||
const routerList: IRouterList[] = [...homeRouter, ...aboutRouter, ...tenantRouter];
|
||||
const routerList: IRouterList[] = [...homeRouter, ...aboutRouter, ...tenantRouter, ...ThreadPoolRouter];
|
||||
export default routerList;
|
||||
|
@ -0,0 +1,76 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@babel/runtime@^7.21.0":
|
||||
version "7.22.15"
|
||||
resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.22.15.tgz#38f46494ccf6cf020bd4eed7124b425e83e523b8"
|
||||
integrity sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.14.0"
|
||||
|
||||
"@types/js-cookie@^2.x.x":
|
||||
version "2.2.7"
|
||||
resolved "https://registry.npmmirror.com/@types/js-cookie/-/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3"
|
||||
integrity sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA==
|
||||
|
||||
ahooks-v3-count@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmmirror.com/ahooks-v3-count/-/ahooks-v3-count-1.0.0.tgz#ddeb392e009ad6e748905b3cbf63a9fd8262ca80"
|
||||
integrity sha512-V7uUvAwnimu6eh/PED4mCDjE7tokeZQLKlxg9lCTMPhN+NjsSbtdacByVlR1oluXQzD3MOw55wylDmQo4+S9ZQ==
|
||||
|
||||
ahooks@^3.7.8:
|
||||
version "3.7.8"
|
||||
resolved "https://registry.npmmirror.com/ahooks/-/ahooks-3.7.8.tgz#3fa3c491cd153e884a32b0c4192fc72cf84c4332"
|
||||
integrity sha512-e/NMlQWoCjaUtncNFIZk3FG1ImSkV/JhScQSkTqnftakRwdfZWSw6zzoWSG9OMYqPNs2MguDYBUFFC6THelWXA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.21.0"
|
||||
"@types/js-cookie" "^2.x.x"
|
||||
ahooks-v3-count "^1.0.0"
|
||||
dayjs "^1.9.1"
|
||||
intersection-observer "^0.12.0"
|
||||
js-cookie "^2.x.x"
|
||||
lodash "^4.17.21"
|
||||
resize-observer-polyfill "^1.5.1"
|
||||
screenfull "^5.0.0"
|
||||
tslib "^2.4.1"
|
||||
|
||||
dayjs@^1.9.1:
|
||||
version "1.11.9"
|
||||
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.9.tgz#9ca491933fadd0a60a2c19f6c237c03517d71d1a"
|
||||
integrity sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==
|
||||
|
||||
intersection-observer@^0.12.0:
|
||||
version "0.12.2"
|
||||
resolved "https://registry.npmmirror.com/intersection-observer/-/intersection-observer-0.12.2.tgz#4a45349cc0cd91916682b1f44c28d7ec737dc375"
|
||||
integrity sha512-7m1vEcPCxXYI8HqnL8CKI6siDyD+eIWSwgB3DZA+ZTogxk9I4CDnj4wilt9x/+/QbHI4YG5YZNmC6458/e9Ktg==
|
||||
|
||||
js-cookie@^2.x.x:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.npmmirror.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
|
||||
integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
|
||||
|
||||
lodash@^4.17.21:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||
|
||||
regenerator-runtime@^0.14.0:
|
||||
version "0.14.0"
|
||||
resolved "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45"
|
||||
integrity sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==
|
||||
|
||||
resize-observer-polyfill@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.npmmirror.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
|
||||
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
|
||||
|
||||
screenfull@^5.0.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.npmmirror.com/screenfull/-/screenfull-5.2.0.tgz#6533d524d30621fc1283b9692146f3f13a93d1ba"
|
||||
integrity sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==
|
||||
|
||||
tslib@^2.4.1:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.npmmirror.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
|
||||
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
|
Loading…
Reference in new issue