Skip to content

cyejing/dam

Repository files navigation

Dam

Build codecov

Dam is High-Performance API Gateway

Features

  • Netty
  • 高性能响应式网络处理
  • 路由表达式灵活匹配Http请求协议体
  • 网关功能可插拔配置
  • 可基于SPI扩展网关功能

Quick Start

EG: dam-example

网关快速启动

添加依赖

<dependency>
    <groupId>cn.cyejing</groupId>
    <artifactId>dam-core</artifactId>
    <version>${new.version}</version>
</dependency>

启动方法

public static void main(String[] args) {
    new DamContainer(ConfigLoader.load(args)).start();
}

配置route.yaml

#route.yaml
routes:
  - id: 196105db9a384d7a93f8102ae46684cb  # 唯一Id
    group: test # 路由分组
    order: 100  # 路由匹配顺序
    global: true # 是否全局路由
    protocol: http # 路由协议
    expressionStr: Path.AntMatch('/dam/**') OR Host.Equals('www.dam.com') 或者 Host.等于('www.dam.cn') # 路由匹配表达式
    filterConfigs: # 路由过滤器配置
    - name: rewrite
      params:
        regex: "/dam/(.*)"
        replacement: "/$1"
    - name: proxy
      params:
        uri: "rlb://test"
instances:
  - group: test
    uri: 192.168.1.1:4843 
  - group: test
    uri: 192.168.1.2:4843
  - group: test
    uri: 192.168.1.3:4843 

网关处理逻辑

  1. 将请求与路由进行匹配
  2. 优先匹配global路由,确定group分组
  3. 按顺序遍历group分组下的所有路由,直到expressionStr匹配正确
  4. 执行该路由过滤器配置

Docs

中文文档

Benchmark

fork from spring-cloud-gateway-bench gitee

TL;DR

Proxy Avg Latency Avg Req/Sec
dam 2.04ms 107.869k
spring cloud gateway 4.68ms 43.827k
linkered 5.23ms 41.988k
zuul 11.08ms 22.757k
none 3.25ms 161.243k

About

High-Performance API Gateway

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages