netty代理转发_lemon: 基于Netty的微服务网关,实现Dubbo、HTTP等代理转发!

Lemon是一个基于Netty的高性能微服务网关框架,支持Dubbo泛化调用和HTTP调用。具备动态发现、通用代理转发等功能。提供HTTP到Dubbo和HTTP的代理,具有高性能、可扩展的过滤器链,支持日志打印、限流、熔断等特性。附带配置介绍和启动指南。
摘要由CSDN通过智能技术生成

lemon

The Micro Service Gateway Framework.

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

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

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

微信交流:请加echo-lry

Architecture

9b3b2bb422718c3335e536e02cf34e7e.png

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

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 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值