You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package router
import (
"context""mosn.io/api"
)
// RouteFactory create router handler for filter hoststypeRouteFactoryinterface {
// Name router factory name// Route factory will be registered as unique componentName() string// Order parameter is used to sort multiple route plugins.// The default value is 0. The smaller the value, the earlier the route plugin is executed.Order() int// Configurator Dynamic route configuration push is supportedConfigurator() Configurator// CreateRouter create route handler with config// Configurator returns the latest route configuration for confCreateRouter(ctx context.Context, confmap[string]interface{}) Handler
}
// Handler host list filter handlertypeHandlerinterface {
// Route filtering by request and invokers address list returns the final list of available services// meta: All hosts must contain the same tag, if anyRoute(ctx context.Context, request api.HeaderMap, invokers []api.HostInfo) (meta api.Metadata, hosts []api.HostInfo)
}
// Configurator Route configuration dynamic push featuretypeConfiguratorinterface {
// Configure Transform dynamic configuration into programmable objects// The transformed object is passed to the RouterFactory CreateRouter// When dynamic configuration is pushed, Configure will be invoked.Configure(factorystring, configstring)
// Configuration This is the route configuration after the latest conversionConfiguration() map[string]interface{}
}
背景
路由、负载均衡等都属于扩展SPI,目前客户的路由策略都是写死在mosn中,通过将路由能力抽象成插件的机制,允许根据不同的场景去做灵活的定制。
写死在mosn中有一些弊端:
什么是路由?
通俗来讲,就是根据一定算法,去筛选目标地址集合得到期望目标地址子集。路由插件化要做的事情:
将编写筛选的算法 开放出去,让客户自行决策,给定目标地址集合,返回目标地址子集。
收益:
目标
思路
开源侧提供route api, 商业版提供插件装载,形成产品能力,实现灵活扩展
方案设计
开源侧Route SPI ( 放到extensions,api无异议,商业版做完验证,提交pr )
------ 以下在商业版mosn中实现, 开源无需关注-----
商业版脚手架支持
商业版mosn route适配
因为mosn框架要实现路由必须满足RouteHandler接口,但是ClusterManager、ClusterSnapshot、HandlerStatus 开源api、pkg迁不出去:
目前商业版是通过CloudRouteHandlerCreator去生成RouteHandler:
因此需要针对插件的RouteFactory创建对应的factory.name -> CloudRouteHandlerCreator:
The text was updated successfully, but these errors were encountered: