Skip to content

Commit

Permalink
feat: added chash (apache#429)
Browse files Browse the repository at this point in the history
* merge master (#1)

* add: Determine duplicate names api for route & upstream (apache#305)

* fix: transaction in routes and upstreams (apache#306)

* add transaction for ssl and consumer (apache#308)

* update ci/cd for api (apache#307)

* update github actions for api ci cd

* fix: working-directory

* fix error

* fix: step name

* fix: mysql config for github action

* test

* use default config

* test: add e2e test for ssl and consumer (apache#309)

* test: add e2e test for ssl and consumer

* fix:  change assert to avoid  the mutual influence of route and service test

* remove useless code

* Feat: added Route Consumer and Upstream (apache#304)

* feat: added routes

* feat: added Consumer

* feat: added upstream

* feat: update SSL

* fix: routes

* feat: added commit command

* feat(route): set empty array for upstreamHeaderList

* fix: e2e test use the same function to set up router (apache#310)

* fix: return all objects when search route & upstream (apache#311)

* fix: route search

* fix: upstream search

* fix(deploy): added missing yarn.lock

* fix: proxy-rewrite plugin in upstream (apache#312)

* fix(SSL): search api

* docs: added tips when deployment

* feat(Deploy): use node alpine image

* fix(Route): set required field for custom redirect

* fix(Route): check if redirect is empty object

* fix(Deploy): add Python installation in dockerfile (apache#316)

Signed-off-by: imjoey <[email protected]>

* fix(Route): update desc for status code

* fix: proxy-path default type is static (apache#318)

* add proxyRewrite test (apache#319)

* feat: bump dependencies version (apache#320)

* feat(Deploy): update Dockerfile

* feat(Deploy): update Deploy Dockerfile

* feat(Pages): update pages (apache#324)

* feat(Pages): update pages

* chore: update routes

* fix(Route): omit upstream_id when not exist

* i18n consumer (apache#325)

* i18n ssl (apache#335)

* nationalization PluginPage component (apache#323)

* i18n upstream (apache#334)

* feat(i18n): set module (apache#336)

* i18n set

* change set to setting

* feat(i18n): metrics module (apache#326)

* i18n metrics

* combine import

* feat(i18n): route module (apache#327)

* i18n route

* combine import

* doc: sync config.yaml from the latest version of APISIX (apache#344)

* i18n route (apache#342)

* i18n actionbar (apache#343)

* fix: transform vars error (apache#347)

* feat(i18n): pluginpage component (apache#345)

* i18n pluginpage

* change pluginpage to PluginPage

* feature: support run in mac system (apache#349)

* combine import (apache#348)

* i18n menu (apache#351)

* i18n PluginPage (apache#350)

* feat: prepare to release (apache#352)

* feat(ManagerAPI): added ASF header

* feat(FE): aded ASF Header

* feat(FE): added ASF header

* fix(FE): update PluginDrawer

* feat: remove some images

* feat: added LICENSE

* feat: update Version

* feat: added NOTICE & CODE_OF_CONDUCT

* feat: added initial CHANGELOG

* feat: rename CODE_OF_CONDUCT

* feat: revert version

* feat: update LICENSE

* feat: update License

* feat(conf): update default preview API (apache#353)

* doc:  add install doc for manager-api (apache#355)

* doc: add install doc for manager-api

* doc: modify folder from build to run

* doc: add ASF header

* fix(ci): resolve lint failures (apache#354)

* fix(deploy): failed to start manager_api (apache#363)

Signed-off-by: imjoey <[email protected]>

* feat(i18n): modify some i18n according to the proposal#331 (apache#366)

* Create CONTRIBUTING.md (apache#368)

* Create CONTRIBUTING.md

* Create ISSUE_TEMPLATE

* Create PULL_REQUEST_TEMPLATE

* doc: remove all ‘incubator’ (apache#367)

* feat(deploy): set gen-config-yaml.sh executable (apache#362)

This also would simplify the docs.

Signed-off-by: imjoey <[email protected]>

* feat(i18n): Use auto load i18n (apache#332) (apache#371)

* Create ci.yml (apache#372)

* feat: release 1.5 (apache#364)

* Feat release 1.5 (apache#358)

* feat(doc): update README

* feat: update CHANGELOG

* doc: add usage of dashbaord

* Revert "doc: add usage of dashbaord"

This reverts commit 5a08c7f43539a44cd0cf0f6175574e59efbd0ab6.

* feat(Doc): update deployment

* feat(Doc): update the deployment

* feat(Doc): update the deployment

* feat: remove incubator text

* doc: modify doc for manager-api runing in local

* feat(Doc): update README

* doc: check env variables and give run.sh power to execute

* feat(Doc): update Deployment

* feat(Doc): update deployment

* doc: modify manager-api build

* feat: update ignore file

Co-authored-by: kv <[email protected]>
Co-authored-by: 琚致远 <[email protected]>

* feat: cherry-pick 4fd0ce7

* feat(compose): remove images

* feat: added line

Co-authored-by: kv <[email protected]>
Co-authored-by: 琚致远 <[email protected]>

* feat: Unified access entrance, only the dashboard port is exposed to … (apache#370)

* feat: Unified access entrance, only the dashboard port is exposed to the outside

* add EOL

* docs: create I18N_USER_GUIDE.md (apache#373)

* docs: create I18N_USER_GUIDE.md

* docs: modify I18N_USER_GUIDE.md

* feat(Doc): added deploy doc for docker (apache#376)

* feat(Doc): added deploy doc for docker

* feat: added CD

* feat(Netlify): added proxy

* feat: update API

* feat: remove console

* feat(Netlify): update redirect rule

* feat: update README

* feat: update README

* update go module proxy (apache#378)

* Update README.md (apache#379)

* Update README.md

* Update README.md

* Create Preview.md

* feat(Doc): added snapshots for Preview

* feat(Doc): update images

* feat(Doc): update images

* Update README.md

* Update netlify.toml

* feat(route): route add params mapping feature (apache#375) (apache#377)

* feat(doc): update deploy manually doc

* fix: mv config.yml to config-default.yml in the latest version of apisix (apache#383)

* fix: wget config-default.yaml the output file need to be named config.yaml (apache#384)

* fix apache#386 wget special output file use -O (apache#387)

* feat(authentication): create authentication module (apache#330)

* feat(authentication): create module typing definition

* feat(authentication): create Login page

* feat(authentication): update typing definition

* feat(authentication): add centent to Login page

* feat(authentication): update typing definition

* feat(authentication): update Login page to add Password and Test method

* feat(authentication): update typing definition to add check and submit function

* feat(authentication): move Test login method to Example

* feat(authentication): add check and submit function

* feat(authentication): add submit function in Login page

* feat(authentication): add test to Password login method

* feat(authentication): change example LoginMethod text

* feat(authentication): add i18n content

* feat(authentication): redirect to index when login success

* feat(i18n): update i18n file import
remove import i18n file of user module manually and try auto import by umi.js

* feat(authentication): create authentication configure items

* fix(authentication): fix logging filter
write back request body for read by PostForm function

* feat(authentication): create authentication controller

* feat(authentication): update dependencies

* fix(authentication): fix logging filter

* feat(authentication): change to session for authentication

* feat(authentication): create authentication filter
use authentication filter to check every request

* feat(authentication): create unit test case

* fix(authentication): change HTTP code when authentication fail request

* feat(authentication): add jwt dependency

* feat(authentication): create session configures

* feat(authentication): change cookie-based session to jwt

* feat(authentication): change cors Access-Control-Allow-Headers header

* feat(authentication): change login page path and error handler

* feat(authentication): create request interceptor to add Authorization header

* feat(authentication): connect to backend login API and i18n

* feat(authentication): create logout page

* feat(authentication): add redirect query to back previous page

* feat(authentication): update LoginMethod definition for logout

* feat(authentication): add logout button

* feat(authentication): improve login page

* fix: clean codes

* fix(authentication): fix unit test crash

* feat(authentication): remove API url setting

* feat(authentication): improve session check

* feat(authentication): redirect to login page when not exist token

* fix: clean codes and add ASF header

* feat(User): update prefix

* fix(ci): fix preview environment (apache#388)

* fix README typo (apache#389)

* fix(ci): fix read configuration file path in docker (apache#390)

* doc: Introducing manager-api (apache#391)

* Update nginx.conf

* Update Dockerfile

* Revert "Update Dockerfile"

This reverts commit ea827bf.

* fix: preview mysql pwd was wrong (apache#393)

* README in Chinese (apache#398)

* feat(doc): added Chinese version of README

* fix(README.zh-CN.md): fix wrong link

* fix(README.zh-CN.md): add link to README.md

* fix(README.zh-CN.md): sync with README.md

* fix(README.zh-CN.md): Fix some translation errors

* fix: dashboard /user/login get error code 405 (apache#397)

* fix: fix dashboard /user/login get error code 405

* fix: modify nginx according to giphoo proposal

* fix(authentication): change Apache APISIX copyright (apache#401)

* fix: configure only necessary items, such as etcd host (apache#405)

* fix: configure only necessary items, such as etcd host

* fix: configure only necessary items, such as etcd host

* fix end of line

* fix: using default admin key (apache#408)

* fix:  we need conf.json when deploying manager-api in local  (apache#409)

* fix: we need conf.json when deploying manager-api in loal

* fix: log error when starting manager failed

* fix: click create ssl prestep not response (apache#407)

* fix: submit setting grafanaURl without validation (apache#413)

* feat: support generate `script` for APISIX (apache#411)

* feat: support generate `script` for APISIX

* not run in `/root` dir

* add  `config.yaml` for APISIX

* fix path

* fix(authentication): change login api url (apache#414)

* fix(authentication): change manager API login path

* fix(authentication): change authentication unit test

* fix(authentication): clean nginx.conf codes

* fix(authentication): change login URL of front end

* fix(authentication): change authentication filter rule

Co-authored-by: kv <[email protected]>
Co-authored-by: nic-chen <[email protected]>
Co-authored-by: 琚致远 <[email protected]>
Co-authored-by: juzhiyuan <[email protected]>
Co-authored-by: Joey <[email protected]>
Co-authored-by: bzp2010 <[email protected]>
Co-authored-by: TikWind <[email protected]>
Co-authored-by: Lien <[email protected]>
Co-authored-by: Rapiz <[email protected]>
Co-authored-by: liuxiran <[email protected]>
Co-authored-by: jie <[email protected]>
Co-authored-by: Rapiz <[email protected]>
Co-authored-by: 琚致远 <[email protected]>
Co-authored-by: Tusdasa翼 <[email protected]>
Co-authored-by: Shuyang Wu <[email protected]>
Co-authored-by: Baoyuan <[email protected]>

* feat: added chash

* feat: update transform

Co-authored-by: kv <[email protected]>
Co-authored-by: nic-chen <[email protected]>
Co-authored-by: 琚致远 <[email protected]>
Co-authored-by: juzhiyuan <[email protected]>
Co-authored-by: Joey <[email protected]>
Co-authored-by: bzp2010 <[email protected]>
Co-authored-by: TikWind <[email protected]>
Co-authored-by: Lien <[email protected]>
Co-authored-by: Rapiz <[email protected]>
Co-authored-by: liuxiran <[email protected]>
Co-authored-by: jie <[email protected]>
Co-authored-by: Rapiz <[email protected]>
Co-authored-by: 琚致远 <[email protected]>
Co-authored-by: Tusdasa翼 <[email protected]>
Co-authored-by: Shuyang Wu <[email protected]>
Co-authored-by: Baoyuan <[email protected]>
  • Loading branch information
17 people authored Sep 1, 2020
1 parent 8f8d173 commit a0d7e0c
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 131 deletions.
2 changes: 2 additions & 0 deletions src/pages/Route/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ const Page: React.FC<Props> = (props) => {
...form2.getFieldsValue(),
...data,
});
setStep2Data({ ...form2.getFieldsValue(), ...params } as RouteModule.Step2Data);
});
return;
}
setStep2Data({ ...form2.getFieldsValue(), ...params } as RouteModule.Step2Data);
}}
Expand Down
263 changes: 154 additions & 109 deletions src/pages/Route/components/Step2/RequestRewriteView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import { Input, Row, Col, InputNumber, Button, Select } from 'antd';
import { PlusOutlined, MinusCircleOutlined } from '@ant-design/icons';
import { useIntl } from 'umi';

import { FORM_ITEM_LAYOUT, FORM_ITEM_WITHOUT_LABEL } from '@/pages/Route/constants';
import {
FORM_ITEM_LAYOUT,
FORM_ITEM_WITHOUT_LABEL,
HASH_KEY_LIST,
HASH_ON_LIST,
} from '@/pages/Route/constants';
import PanelSection from '@/components/PanelSection';
import styles from '../../Create.less';
import { fetchUpstreamList } from '../../service';
Expand All @@ -48,117 +53,157 @@ const RequestRewriteView: React.FC<Props> = ({ data, form, disabled, onChange })
});
}, []);
const renderUpstreamMeta = () => (
<Form.List name="upstreamHostList">
{(fields, { add, remove }) => (
<>
<Form.Item label="类型" name="type" rules={[{ required: true }]}>
<Select disabled={upstreamDisabled} onChange={(params) => onChange({ type: params })}>
<Select.Option value="roundrobin">roundrobin</Select.Option>
<Select.Option value="chash">chash</Select.Option>
</Select>
</Form.Item>
{step2Data.type === 'chash' && (
<>
{fields.map((field, index) => (
<Form.Item
required
key={field.key}
{...(index === 0 ? FORM_ITEM_LAYOUT : FORM_ITEM_WITHOUT_LABEL)}
label={
index === 0 ? formatMessage({ id: 'route.request.override.domain.name.or.ip' }) : ''
}
extra={
index === 0
? formatMessage({ id: 'route.request.override.use.domain.name.default.analysis' })
: ''
}
>
<Row style={{ marginBottom: '10px' }} gutter={16}>
<Col span={9}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'host']}
rules={[
{
required: true,
message: formatMessage({ id: 'route.request.override.input.domain.or.ip' }),
},
{
pattern: new RegExp(
/(^([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])(\.(25[0-5]|1\d{2}|2[0-4]\d|[1-9]?\d)){3}$|^(?![0-9.]+$)([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+){0,}$)/,
'g',
),
message: formatMessage({ id: 'route.request.override.domain.or.ip.rules' }),
},
]}
>
<Input
placeholder={formatMessage({
id: 'route.request.override.domain.name.or.ip',
})}
disabled={upstreamDisabled}
/>
</Form.Item>
</Col>
<Col span={4}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'port']}
rules={[
{
required: true,
message: formatMessage({ id: 'route.request.override.input.port.number' }),
},
]}
>
<InputNumber
placeholder={formatMessage({ id: 'route.request.override.port.number' })}
disabled={upstreamDisabled}
min={1}
max={65535}
/>
</Form.Item>
</Col>
<Col span={4} offset={1}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'weight']}
rules={[
{
required: true,
message: formatMessage({ id: 'route.request.override.input.weight' }),
},
]}
>
<InputNumber
placeholder={formatMessage({ id: 'route.request.override.weight' })}
disabled={upstreamDisabled}
min={0}
max={1000}
/>
</Form.Item>
</Col>
<Col>
{!upstreamDisabled &&
(fields.length > 1 ? (
<MinusCircleOutlined
style={{ margin: '0 8px' }}
onClick={() => {
remove(field.name);
}}
/>
) : null)}
</Col>
</Row>
</Form.Item>
))}
{!upstreamDisabled && (
<Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
<Button
type="dashed"
onClick={() => {
add();
}}
>
<PlusOutlined /> {formatMessage({ id: 'route.request.override.create' })}
</Button>
</Form.Item>
)}
<Form.Item label="Hash On" name="hash_on">
<Select disabled={upstreamDisabled}>
{HASH_ON_LIST.map((item) => (
<Select.Option value={item} key={item}>
{item}
</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item label="Key" name="key">
<Select disabled={upstreamDisabled}>
{HASH_KEY_LIST.map((item) => (
<Select.Option value={item} key={item}>
{item}
</Select.Option>
))}
</Select>
</Form.Item>
</>
)}
</Form.List>
<Form.List name="upstreamHostList">
{(fields, { add, remove }) => (
<>
{fields.map((field, index) => (
<Form.Item
required
key={field.key}
{...(index === 0 ? FORM_ITEM_LAYOUT : FORM_ITEM_WITHOUT_LABEL)}
label={
index === 0
? formatMessage({ id: 'route.request.override.domain.name.or.ip' })
: ''
}
extra={
index === 0
? formatMessage({
id: 'route.request.override.use.domain.name.default.analysis',
})
: ''
}
>
<Row style={{ marginBottom: '10px' }} gutter={16}>
<Col span={9}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'host']}
rules={[
{
required: true,
message: formatMessage({
id: 'route.request.override.input.domain.or.ip',
}),
},
{
pattern: new RegExp(
/(^([1-9]?\d|1\d{2}|2[0-4]\d|25[0-5])(\.(25[0-5]|1\d{2}|2[0-4]\d|[1-9]?\d)){3}$|^(?![0-9.]+$)([a-zA-Z0-9_-]+)(\.[a-zA-Z0-9_-]+){0,}$)/,
'g',
),
message: formatMessage({
id: 'route.request.override.domain.or.ip.rules',
}),
},
]}
>
<Input
placeholder={formatMessage({
id: 'route.request.override.domain.name.or.ip',
})}
disabled={upstreamDisabled}
/>
</Form.Item>
</Col>
<Col span={4}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'port']}
rules={[
{
required: true,
message: formatMessage({
id: 'route.request.override.input.port.number',
}),
},
]}
>
<InputNumber
placeholder={formatMessage({ id: 'route.request.override.port.number' })}
disabled={upstreamDisabled}
min={1}
max={65535}
/>
</Form.Item>
</Col>
<Col span={4} offset={1}>
<Form.Item
style={{ marginBottom: 0 }}
name={[field.name, 'weight']}
rules={[
{
required: true,
message: formatMessage({ id: 'route.request.override.input.weight' }),
},
]}
>
<InputNumber
placeholder={formatMessage({ id: 'route.request.override.weight' })}
disabled={upstreamDisabled}
min={0}
max={1000}
/>
</Form.Item>
</Col>
<Col>
{!upstreamDisabled &&
(fields.length > 1 ? (
<MinusCircleOutlined
style={{ margin: '0 8px' }}
onClick={() => {
remove(field.name);
}}
/>
) : null)}
</Col>
</Row>
</Form.Item>
))}
{!upstreamDisabled && (
<Form.Item {...FORM_ITEM_WITHOUT_LABEL}>
<Button
type="dashed"
onClick={() => {
add();
}}
>
<PlusOutlined /> {formatMessage({ id: 'route.request.override.create' })}
</Button>
</Form.Item>
)}
</>
)}
</Form.List>
</>
);

const renderTimeUnit = () => <span style={{ margin: '0 8px' }}>ms</span>;
Expand Down
16 changes: 16 additions & 0 deletions src/pages/Route/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const DEFAULT_STEP_2_DATA: RouteModule.Step2Data = {
upstreamHostList: [{} as RouteModule.UpstreamHost],
upstreamHeaderList: [],
upstreamPath: undefined,
type: 'roundrobin',
mappingStrategy: undefined,
rewriteType: 'keep',
timeout: {
Expand All @@ -82,3 +83,18 @@ export const INIT_CHART = {
selected: {},
hovered: {},
};

export const HASH_KEY_LIST = [
'remote_addr',
'host',
'uri',
'server_name',
'server_addr',
'request_uri',
'query_string',
'remote_port',
'hostname',
'arg_id',
];

export const HASH_ON_LIST = ['vars', 'header', 'cookie', 'consumer'];
12 changes: 11 additions & 1 deletion src/pages/Route/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export const transformStepData = ({
upstream_header[header.header_name] = header.header_value || '';
});

const chashData: any = {};
if (step2Data.type === 'chash') {
chashData.key = step2Data.key;
chashData.hash_on = step2Data.hash_on;
}

let redirect: RouteModule.Redirect = {};
if (step1Data.redirectOption === 'disabled') {
redirect = {};
Expand Down Expand Up @@ -70,7 +76,8 @@ export const transformStepData = ({
return [key, operator, value];
}),
upstream: {
type: 'roundrobin',
type: step2Data.type,
...chashData,
nodes,
timeout: step2Data.timeout,
},
Expand Down Expand Up @@ -199,6 +206,9 @@ export const transformRouteData = (data: RouteModule.Body) => {
const step2Data: RouteModule.Step2Data = {
upstream_protocol,
upstreamHeaderList,
type: upstream ? upstream.type : 'roundrobin',
hash_on: upstream ? upstream.hash_on : undefined,
key: upstream ? upstream.key : undefined,
upstreamHostList: transformUpstreamNodes(upstream?.nodes),
upstream_id,
upstreamPath: upstream_path?.to,
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Route/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ declare namespace RouteModule {

type Step2Data = {
upstream_protocol: 'http' | 'https' | 'keep';
type: 'roundrobin' | 'chash';
hash_on?: string;
key?: string;
upstreamHostList: UpstreamHost[];
mappingStrategy: string | undefined;
rewriteType: string | undefined;
Expand Down Expand Up @@ -121,6 +124,8 @@ declare namespace RouteModule {
vars: [string, Operator, string][];
upstream: {
type: 'roundrobin' | 'chash';
hash_on?: string;
key?: string;
nodes: {
[key: string]: number;
};
Expand Down
Loading

0 comments on commit a0d7e0c

Please sign in to comment.