go-kratos / gateway Goto Github PK
View Code? Open in Web Editor NEWA high-performance API Gateway with middlewares, supporting HTTP and gRPC protocols.
License: MIT License
A high-performance API Gateway with middlewares, supporting HTTP and gRPC protocols.
License: MIT License
Line 95 in 8d073a2
Blocking in this line:
Line 85 in eafdf84
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.
Is there a specific roadmap and release schedule?
We may be able to provide some development assistance. : )
open source is strict thing.
API Gateway Modules:
Transport
-HTTP
-GRPC
Router
-Path
-Prefix
-Regex
Endpoint
-Middleware
--Metrics/Tracing/Logging
--Device/Metadata
--CircuitBreaker
--Ratelimit
--Timeout
--Retry
--Auth
Upstream
-Selector
-Balancer
-Health
SerivceManagement:
- Middleware
- Endpoint
- Upstream
Transport -> Router -> Middleware -> Endpoint -> Upstream
Dashboards:
Go Gateway:
References:
不知道是不是我理解错了,测试代理 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)),
),
}
kratos和gateway trace链路没有串联起来
现在版本只支持http代理转发,希望支持https转发。谢谢
这个问题因为啥?
什么时候发布1.0版本呢
rpc error: code = Unavailable desc = error reading from server: EOF
这里的 strings.HasPrefix
是不是应该写成 !strings.HasPrefix
呢?感觉这里应该想写“如果配置不是 grpc 协议或者不是 grpc 响应头就直接返回“
1.隔离保护:限流、鉴权认证、参数校验、熔断降级、缓存、跨域cors、黑白名单、链路加密、健康检查、超时控制
2.流量调度:动态路由、染色、灰度、单元化、流量复制
3.请求转换:负载协议转化、请求映射与绑定(path\header\query\cookie)、字段过滤
4.观测:tracing、metircs、logging
5.api生命周期管理:创建、测试、发布、授权、代码⽣成、⽂档、mock、更新、下线
Nginx 架构痛点问题:
1.配置维护复杂
2.缺乏私有协议转换能力(包接口)
3.插件开发困难:lua
4.缺乏api生命周期管理
6.路由策略不够丰富,难以支持业务维度的流量调度策略
7.缺乏稳定性策略
数据面配置:
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
控制面流程:
添加服务
-> 添加分组 -> 域名 -> 中间件
-> 添加接口 -> 路由 -> 中间件
-> 添加上游 -> 服务发现 -> 健康检查
proxy.buildEndpoint 方法返回 http.Handler。在第 521 行的 return 语句返回了一个 http.HandlerFunc 类型的函数对象。
因为 http.HandlerFunc 类型已经是 http.Handler 的实现类型了,所以在这里并没有必要强转类型。这次类型强转是没有必要的。
Line 251 in abf713b
curl --location --request POST 'http://127.0.0.1:8080/helloworld.Greeter/SayHello'
--data-raw ''
reply, err = handler(ctx, req)
startTime := time.Now()
Need to?
startTime := time.Now()
reply, err = handler(ctx, req)
Hope to support https->http
example/benchmark/compose 目录下是否可以添加 nginx 代理的配置,以便用户对比 nginx 和其他压测方案?
flag.StringVar(&ctrlService, "ctrl.service", "", "control service host, eg: http://127.0.0.1:8000")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.