Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.
This repository was archived by the owner on May 30, 2022. It is now read-only.

Some ideas about using RPC with SOFABoot #199

Open
@antergone

Description

@antergone

现在注解是在ReferenceAnnotationBeanPostProcessor阶段处理,扫描注解创建RPC代理对象,并通过反射的方式放到了注入点。

想法:

  1. 能否直接提供一个静态类工厂类(SofaRpcFactory)和一个通用配置文件(SofaProperties)。在这个工厂内提供create方法,内部做各种RPC初始化操作,并返回RPC动态代理接口对象。
    TestFacade SofaRpcFactory.create(TestFacade.class, props)
    这样做可以直接将Client初始化完全黑盒在RPC组件内,将Facade的生命周期绑定到spring容器中去,初始化阶段不再依赖注解,显式的用@Bean将RPC和Spring连接起来。

这个想法来源于Retrofit2的客户端构造过程:
retrofit2.Retrofit#create

  1. 提供EnableSofaRPC注解,通过import的方式激活Registrar,用Registrar配合Scanner进行扫描注册Bean。这里可以定一个规范,本地要有一个Facade接口继承其他服务的Facade包并带上@SofaRpcClient注解,或者开发者需要给出一个调用Facade 的Class列表供框架扫描。

这个想法来源于 Spring Cloud FeignClient的做法

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions