Alanxtl commented on issue #3686:
URL: https://github.com/apache/dubbo-go/issues/3686#issuecomment-5351622733
现在的 PR #3687 重新建立了一套 extension runtime
系统。</p><p>可是现有能力已经足够覆盖大部分需求呀:</p><div><div><div>
现有能力 | 可以承担的职责
-- | --
extension.NewRegistry | 注册扩展配置
extension.SetFilter / GetFilter | 注册和创建 filter
common/extension.Config | 扩展配置的名称和配置对象
InstanceOptions + koanf | 加载 YAML
Invoker.GetURL() | 获取服务、group、version
Invocation.MethodName() | 获取方法名
</div></div></div><p>尤其是 resource,不需要新增 <code dir="ltr">Resource</code>
类型。Hystrix filter 本身已经可以拿到:</p><pre dir="ltr"><code>func (f *Filter) Invoke(
ctx context.Context,
invoker base.Invoker,
invocation base.Invocation,
) result.Result</code></pre><p>因此它可以直接通过:</p><pre
dir="ltr"><code>invoker.GetURL()
invocation.MethodName()</code></pre><p>生成:</p><pre
dir="ltr"><code>greet.GreetService:::Greet</code></pre><p>不需要核心额外绑定一个 <code
dir="ltr">Resource</code> 对象。</p><p>更简单的改法是:</p><ol start="1"><li>扩展继续通过现有
<code dir="ltr">extension.SetFilter</code> 注册 filter。</li><li>扩展配置继续实现现有的 <code
dir="ltr">extension.Config</code>。</li><li>给 <code dir="ltr">Config</code>
增加创建配置实例和初始化能力。</li><li><code dir="ltr">client.WithExtension</code>、<code
dir="ltr">server.WithExtension</code>、<code
dir="ltr">dubbo.WithExtension</code> 只负责把扩展配置加入对应 options。</li><li><code
dir="ltr">dubbo.Load()</code> 根据 <code dir="ltr">Prefix()</code> 找到扩展配置,用现有
koanf 解码。</li><li>初始化时由入口决定作用域:<ul><li><code dir="ltr">client</code> 自动是
consumer</li><li><code dir="ltr">server</code> 自动是 provider</li><li><cod
e dir="ltr">dubbo</code> 自动是 instance</li></ul></li><li>扩展内部根据 scope 自动把已经注册的
filter 加入现有 filter chain。</li></ol><p>这样不需要新增:</p><pre dir="ltr"><code>RawNode
RawConfig
Resource
FilterSpec
RoleNone</code></pre><p>甚至 <code dir="ltr">Context</code>
也可以暂时不要。</p><p>需要补的只是现有 <code dir="ltr">extension.Config</code> 当前能力太弱:</p><pre
dir="ltr"><code>type Config interface {
Prefix() string
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]