Welcome to FlowZap, the App to diagram with Speed, Clarity and Control.

API 网关工作流程

patterns

API 网关模式,包含**请求认证**、**速率限制**、**请求路由到后端服务**、**响应聚合**和**错误处理**。

完整 FlowZap 代码

Client { # Client
n1: circle label:"Start"
n2: rectangle label:"Send API request"
n3: rectangle label:"Receive response"
n4: circle label:"End"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> Gateway.n5.handle(top) [label="HTTP Request"]
n3.handle(right) -> n4.handle(left)
}
Gateway { # API Gateway
n5: rectangle label:"Receive incoming request"
n6: rectangle label:"Validate API key"
n7: diamond label:"Authenticated?"
n8: rectangle label:"Check rate limits"
n9: rectangle label:"Return 401 Unauthorized"
n10: diamond label:"Within rate limit?"
n11: rectangle label:"Route to service"
n12: rectangle label:"Return 429 Too Many Requests"
n13: rectangle label:"Transform response"
n5.handle(right) -> n6.handle(left)
n6.handle(right) -> n7.handle(left)
n7.handle(right) -> n8.handle(left) [label="Yes"]
n7.handle(bottom) -> n9.handle(top) [label="No"]
n8.handle(right) -> n10.handle(left)
n9.handle(top) -> Client.n3.handle(bottom) [label="401"]
n10.handle(right) -> n11.handle(left) [label="Yes"]
n10.handle(bottom) -> n12.handle(top) [label="No"]
n11.handle(bottom) -> Backend.n14.handle(top) [label="Forward"]
n12.handle(top) -> Client.n3.handle(bottom) [label="429"]
n13.handle(top) -> Client.n3.handle(bottom) [label="Response"]
}
Backend { # Backend Service
n14: rectangle label:"Process request"
n15: diamond label:"Request valid?"
n16: rectangle label:"Execute business logic"
n17: rectangle label:"Return error response"
n18: rectangle label:"Return success response"
n14.handle(right) -> n15.handle(left)
n15.handle(right) -> n16.handle(left) [label="Yes"]
n15.handle(bottom) -> n17.handle(top) [label="No"]
n16.handle(right) -> n18.handle(left)
n17.handle(top) -> Gateway.n13.handle(bottom) [label="Error"]
n18.handle(top) -> Gateway.n13.handle(bottom) [label="Success"]
}

相关模板

断路器工作流

patterns

断路器弹性模式,包含闭合、打开和半开状态,用于保护服务免受级联故障,并带有自动恢复测试。

Saga 模式工作流

patterns

针对订单、支付和配送服务的 Saga 编排模式分布式事务工作流,在失败时自动触发补偿回滚。