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

Some ideas about using RPC with SOFABoot #199

Open
antergone opened this issue Jul 8, 2019 · 1 comment
Open

Some ideas about using RPC with SOFABoot #199

antergone opened this issue Jul 8, 2019 · 1 comment

Comments

@antergone
Copy link

现在注解是在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的做法

@sofastack-bot sofastack-bot bot changed the title 关于SOFABoot使用RPC的一些想法 Some ideas about using RPC with SOFABoot Jul 8, 2019
@sofastack-bot
Copy link

sofastack-bot bot commented Jul 8, 2019

Hi @antergone, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

The annotation is now processed in the ReferenceAnnotationBeanPostProcessor stage, which scans the annotation to create the RPC proxy object and puts it into the injection point by reflection. Ideas: 1. Can you provide a static class factory class (SofaRpcFactory) and a generic configuration file (SofaProperties) directly. The create method is provided in this factory, and various RPC initialization operations are performed internally, and the RPC dynamic proxy interface object is returned. TestFacade SofaRpcFactory.create(TestFacade.class, props). This can directly initialize the client to the black box in the RPC component, bind the lifecycle of the facade to the spring container, and the initialization phase no longer relies on annotations. Explicitly connect RPC and Spring with @Bean. This idea comes from the client-side construction process of Retrofit2: retrofit2.Retrofit#create 2. Provides EnableSofaRPC annotations, activates Registrar by importing, and uses Registrar with Scanner to scan and register beans. Here you can define a specification. Locally, there must be a Facade interface inheriting the Facade package of other services with the annotation of @SofaRpcClient, or the developer needs to give a list of classes calling Facade for the framework to scan. This idea comes from the practice of Spring Cloud FeignClient

@caojie09 caojie09 transferred this issue from sofastack/sofa-boot Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant