1 Star 0 Fork 984

董健文 / incubator-shenyu

forked from Apache ShenYu / shenyu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

应用于所有微服务场景,可扩展、高性能、响应式的 API 网关解决方案

https://shenyu.apache.org/

English | 简体中文

github forks github stars github contributors



架构


为什么叫 ShenYu

ShenYu (神禹)是我们古代君王夏禹的尊称(后世也尊称大禹),为造福百姓,成功治理黄河水患,留下了三过家门而不入的感人故事。其和尧舜并称为中国古代最伟大的三位君王。

  • 首先,取名为 ShenYu 是弘扬我们中华文明的传统美德。

  • 其次,网关最最重要的是对流量的治理。

  • 最后,社区将会以公平,公正,公开,任人唯贤的做事方式,致敬神禹的同时也符合 Apache Way。


功能特点

  • 提供了诸如限流、熔断、转发 、重写、重定向、路由、监控等插件;
  • 支持 HTTP、RESTFul、WebSocket、Dubbo、 gRPC、 Tars、 Spring Cloud 代理;
  • 支持热插拔,用户可以定制化开发;
  • 为了灵活的适配,选择器和规则可以动态的适配;
  • 支持集群部署;
  • 支持 A/B 测试和灰度发布。

快速体验

启动Apache ShenYu Admin

> docker pull apache/shenyu-admin
> docker network create shenyu
  • 使用 h2 来存储后台数据:
> docker run -d -p 9095:9095 --net shenyu apache/shenyu-admin

启动Apache ShenYu Bootstrap

> docker network create shenyu
> docker pull apache/shenyu-bootstrap
> docker run -d -p 9195:9195 --net shenyu apache/shenyu-bootstrap

设置路由规则

{
  "name" : "Shenyu",
  "data" : "hello world"
}
  • 单机模式设置路由规则

Headers 中添加 localKey: 123456。如果需要自定义 localKey,可以使用 sha512 工具根据明文生成 key,并更新 shenyu.local.sha512Key 属性。

curl --location --request POST 'http://localhost:9195/shenyu/plugin/selectorAndRules' \
--header 'Content-Type: application/json' \
--header 'localKey: 123456' \
--data-raw '{
    "pluginName": "divide",
    "selectorHandler": "[{\"upstreamUrl\":\"127.0.0.1:8080\"}]",
    "conditionDataList": [{
        "paramType": "uri",
        "operator": "match",
        "paramValue": "/**"
    }],
    "ruleDataList": [{
        "ruleHandler": "{\"loadBalance\":\"random\"}",
        "conditionDataList": [{
            "paramType": "uri",
            "operator": "match",
            "paramValue": "/**"
        }]
    }]
}'
{
  "name" : "Shenyu",
  "data" : "hello world"
}

插件

无论请求何时进入,ShenYu 会通过响应链执行所有已打开的插件。

插件是 ShenYu 的灵魂,并且插件也是可扩展和热插拔的。

不同的插件实现不同的功能。

当然,用户也可以定制化插件去满足他们自己的需求。

如果你有定制化插件的需求,请参看这里:custom-plugin


选择器和规则

选择器和规则会根据 HTTP 的请求头来路由你的请求。

选择器是你的第一个路由,它是粗粒度的,举个例子,模块级别。

规则是你的第二个路由,即你认为你的请求应该做什么,举个例子,模块中的方法级别。

选择器和规则只匹配一次,然后返回匹配。因此,最粗粒度应排在最后。


数据缓存 & 数据同步

所有的数据都被缓存在 JVM 的 ConcurrentHashMap 中,所以它非常快。

当用户在后台界面改变配置信息时,ShenYu 通过监听 ZooKeeper 节点(或 WebSocket 推送,HTTP长轮询)来动态更新缓存。


必要条件

  • JDK 1.8+

文档 & 网站

EN doc CN doc


Github stars趋势

Stargazers over time


目前已知用户

为了便于登记,欢迎已经使用了 ShenYu 的公司在 https://github.com/apache/shenyu/issues/68 注册。(仅适用于开源用户)

所有用户 : Known Users

# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # header: license: spdx-id: Apache-2.0 copyright-owner: Apache Software Foundation paths-ignore: - '**/target/**' - '**/logs/**' - '**/*.log' - '**/*.tar.gz' - '**/spring.factories' - '**/spring.provides' - '/script/**' - '**/*.json' - '**/*.iml' - '**/.idea/**' - '**/*.classpath' - '**/.project' - '**/.settings/**' - '**/dependency-reduced-pom.xml' - '**/.gitignore' - '**/.gitmodules' - '**/.git/**' - '**/.travis.yml' - '**/.codecov.yml' - '**/.mvn/jvm.config' - '**/.mvn/wrapper/maven-wrapper.properties' - '**/.github/**' - '**/*.md' - '**/*.MD' - '**/*.txt' - '**/docs/**' - '**/.babelrc' - '**/.editorconfig' - '**/.eslintignore' - '**/assets/**' - '**/dist/**' - '**/etc/**' - '**/node/**' - '**/node_modules/**' - '**/test/coverage/**' - '.mvn' - 'shenyu-dist' - 'shenyu-dashboard' - 'DISCLAIMER' - 'licenses' - 'LICENSE' - 'NOTICE' comment: on-failure

简介

JAVA语言中高性能,可插拔,响应式API网关 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/djw_1997/incubator-shenyu.git
git@gitee.com:djw_1997/incubator-shenyu.git
djw_1997
incubator-shenyu
incubator-shenyu
master

搜索帮助

14c37bed 8189591 565d56ea 8189591