1 Star 0 Fork 47

西楼雪 / lemon

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

lemon

The Micro Service Gateway Framework.

Lemon is a high-performance, Java based open source gateway framework.

基于Netty4的微服务网关(Micro Service Gateway)。同时支持Dubbo泛化调用和HTTP调用,并支持自定义实现微服务网关请求的代理转发功能。

GitHubhttps://github.com/yu120/lemon

QQ交流群:微服务基础架构(191958521)

微信交流:请加echo-lry

Architecture

lemon

Features

  • HTTP to Dubbo Gateway
  • HTTP to HTTP Gateway
  • High Performance
  • Dynamic Discovery
  • Generalized Agent
  • Extensible Chain of Responsibility
  • Two-way LOG Printing Filter

TODO

  • HTTP proxy Motan
  • HTTP proxy SpringCloud
  • TCP proxy other
  • CircuitBreaker Filter
  • Degrade Filter
  • Idempotent Filter
  • Limiter Filter
  • Retry Filter

Config Introduce

Config Path: src/main/resources/lemon.yml

port: 8080
application: lemon
# Netty IO/Work thread number
ioThread: 0
workThread: 0
# Body max content length, 64 * 1024 * 1024 = 64 MB
maxContentLength: 67108864
# Max client connection channel number
maxChannel: 100000
# 
bizCoreThread: 20
bizMaxThread: 200
bizQueueCapacity: 800
bizKeepAliveTime: 60000
# Custom Fixed Response Header Parameter Configuration
resHeaders:
  Connection: keep-alive
  Accept-Encoding: gzip,deflate
  Content-Type: application/json;charset=UTF-8
originalHeaders: [Connection, Content-Type, Set-Cookie, Call-Code, Call-Message]
# Dubbo lemon config
dubbo:
  registryAddress: zookeeper://127.0.0.1:2181
  metadataAddress: zookeeper://127.0.0.1:2181
# Direct forwarding HTTP rule
services:
  - category: jsoup
    service: /baidu/**
    url: https://www.baidu.com
  - category: jsoup
    service: /oschina/**
    url: https://www.oschina.net

Dubbo Lemon

The support apache dubbo 2.7.2 generic service proxy.

Format:

URL:
http://[host]:[port]/lemon/[application]/[service or serviceSimpleName]/[method]?group=[group]&version=[version]

Body:
List[Map{...}, Map{...}, ...]

Example:

http://localhost:8080/lemon/micro-dubbo-provider/cn.micro.biz.dubbo.provider.DemoService/test

or

http://localhost:8080/lemon/micro-dubbo-provider/demo/test

[{"name":"lemon", "age":23}, {"10001"}]

HTTP Lemon

Proxy forwarding using jsoup.

http://[host]:[port]/lemon/[service]/**?group=[group]&version=[version]

Motan Lemon

TODO

Spring Cloud Lemon

TODO

Packing and Installation

mvn clean install -Denforcer.skip=true -Dmaven.test.skip=true

The target directory: target/lemon-1.0.0-SNAPSHOT-dist.tar.gz

After successful execution, lemon-1.0.0-SNAPSHOT-dist.tar.gz will be generated in the directory of target.

Start lemon

> tar -zxvf lemon-1.0.0-SNAPSHOT-dist.tar.gz
> cd bin
> ./app start
# Usage: app { console | start | stop | restart | status | dump }

Use Arthas

Alibaba Arthas

arthas-boot:

> wget https://alibaba.github.io/arthas/arthas-boot.jar
> java -jar arthas-boot.jar

as.sh:

> curl -L https://alibaba.github.io/arthas/install.sh | sh
> ./as.sh

可以直接访问:http://127.0.0.1:8563

Start service provider

The metadata report config must be used.

import DemoService;
import DemoServiceImpl;
import org.apache.dubbo.config.*;

public class ProviderDemo {

    public static void main(String[] args) throws Exception {
        // Implementation
        DemoService demoService = new DemoServiceImpl();

        // Application Info
        ApplicationConfig application = new ApplicationConfig();
        application.setName("micro-dubbo-provider");

        // Registry Info
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("zookeeper://127.0.0.1:2181");

        // Metadata Report Info
        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
        metadataReportConfig.setAddress("zookeeper://127.0.0.1:2181");

        // Protocol
        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("dubbo");
        protocol.setPort(12345);
        protocol.setThreads(200);

        // Exporting: In case of memory leak, please cache.
        ServiceConfig<DemoService> service = new ServiceConfig<>();
        service.setApplication(application);
        // Use setRegistries() for multi-registry case
        service.setRegistry(registry);
        // Use setProtocols() for multi-protocol case
        service.setProtocol(protocol);
        service.setMetadataReportConfig(metadataReportConfig);
        service.setInterface(DemoService.class);
        service.setRef(demoService);

        // Local export and register
        service.export();
        System.in.read();
    }

}

License

Lemon is under the MIT license. See the LICENSE file for details.

MIT License Copyright (c) 2019 lemon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于Netty的微服务网关,实现Dubbo、HTTP等代理转发! 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/349099139/lemon.git
git@gitee.com:349099139/lemon.git
349099139
lemon
lemon
master

搜索帮助

14c37bed 8189591 565d56ea 8189591