Code Monkey home page Code Monkey logo

gateway's Issues

源码中有个不必要的 "http.Handler"

proxy.buildEndpoint 方法返回 http.Handler。在第 521 行的 return 语句返回了一个 http.HandlerFunc 类型的函数对象。
因为 http.HandlerFunc 类型已经是 http.Handler 的实现类型了,所以在这里并没有必要强转类型。这次类型强转是没有必要的。

return http.Handler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {

architect

1.隔离保护:限流、鉴权认证、参数校验、熔断降级、缓存、跨域cors、黑白名单、链路加密、健康检查、超时控制
2.流量调度:动态路由、染色、灰度、单元化、流量复制
3.请求转换:负载协议转化、请求映射与绑定(path\header\query\cookie)、字段过滤
4.观测:tracing、metircs、logging
5.api生命周期管理:创建、测试、发布、授权、代码⽣成、⽂档、mock、更新、下线

Nginx 架构痛点问题:
1.配置维护复杂
2.缺乏私有协议转换能力(包接口)
3.插件开发困难:lua
4.缺乏api生命周期管理
6.路由策略不够丰富,难以支持业务维度的流量调度策略
7.缺乏稳定性策略

roadmap question

Is there a specific roadmap and release schedule?
We may be able to provide some development assistance. : )

config

数据面配置:

  • Gateway
    • HTTP
    • GRPC
  • Endpoint
    • Host
    • Route
    • Middleware
    • Upstream
  • Upstream
    • HeathCheck
    • Discovery
gateways:
- port: 80
  address: 0.0.0.0
- port: 443 # TLS is not currently supported
  address: 0.0.0.0

services:
name: some_endpoint
namespace: api.kratos
http:
- methods:
  - POST
  matchs: # path, prefix, regex, queries, headers (and)
  - prefix: /api
  - path: /api/users
  - regex: /api/users/[0-9]+
  - queries:
      username: kratos
  backends: 
  - upstream: some1_upstream
    weight: 20
  - upstream: some2_upstream
    weight: 80
  middlewares:
  - logging: {}
  - metrics: {}
  - retres:
    attempts: 3
    retryOn: [502, 503, 504]

upstreams:
- name: some1_upstream
  health_check:
    timeout: 1s
    interval: 60s
    tcp_health_check: {} # http_health_check, grpc_health_check
  selector:
    discovery:
      region: sh
      zone: sh001
      env: prod
      cluster: group1
- name: some2_upstream
  health_check:
    timeout: 1s
    interval: 60s
    tcp_health_check: {} # http_health_check, grpc_health_check
  selector:
    static:
      - port: 8000
        address: 127.0.0.1
        weight: 100

控制面流程:

  • Service
  • Group
  • Endpoint
  • Middleware
  • Upstream
添加服务 
-> 添加分组 -> 域名 -> 中间件
-> 添加接口 -> 路由 -> 中间件
-> 添加上游 -> 服务发现 -> 健康检查

Bug: Fail to run

Blocking in this line:

go log.Fatal(http.ListenAndServe(pprofAddr, nil))

I guess that go can not start a goroutine until the parameter is passed into the function. I would commit a PR to fix it.

Dockerfile 问题

gateway 工程的 go.mod 是 1.19,但 Dockerfile 里用到的基础镜像是 golang:1.17。

FROM golang:1.17 AS builder

另外 gateway 工程的命令行参数 conf 期望传具体配置的路径,如 "/data/conf/config.yaml",而 Dockerfile 的默认配置指定的是目录名。

CMD ["./gateway", "-conf", "/data/conf"]

现在 gateway 工程有打好的镜像吗?比如 "ghcr.io/go-kratos/gateway" 这样的。

中间件 tracing 在 HTTP 模式下没有向 Endpoint HTTP 后端传递 traceparent 头,trace 无法关联

不知道是不是我理解错了,测试代理 HTTP 后端,没有传递 traceparent
生成的链路一个是 gateway 的,一个是被代理后端的,id 不相同

我尝试在 middleware/tracing/tracing.go 中增加设置 req header traceparent 后,可以完整的关联 traceID

被代理后端配置如下:
基于标准的 kratos new helloworld 模板生成的代码
并在 server/http.go 中修改

var opts = []http.ServerOption{
    http.Middleware(
        recovery.Recovery(),
        metadata.Server(),
        tracing.Server(tracing.WithTracerProvider(tp)),
    ),
}

design

添加 nginx 代理 example?

example/benchmark/compose 目录下是否可以添加 nginx 代理的配置,以便用户对比 nginx 和其他压测方案?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.