springCloud gateway 的样例工程,包含功能:
授权
验签
动态路由
日志
流控,降级
先下载 https://github.com/weweibuy/weweibuy-framework mvn install
参考: AuthenticationGatewayFilterFactory
参考: SystemRequestParamGatewayFilterFactory VerifySignatureGatewayFilterFactory
基于JDBC + mybatis 实现:
参考: JdbcRouteDefinitionLocator
JdbcRouterManger
查询与刷新路由服务端点:
JdbcRouterManger
参考: AccessLogFilter
参考: Sentinel
ILoadBalancer对服务有自己的缓存,定时(默认30s)到注册中心更新缓存的服务信息. 当服务下线时,如果本地缓存不清除,将导致将请求转发到一个不可用的服务上,直到下次定时更新服务. 可以通过注册中心监听服务健康状态(例如consul的watches),通知一个MQ服务,gateway监听MQ消息刷新本地缓存服务信息 参考: RocketServerChangeListener