1 Star 4 Fork 0

刘牌 / rpc-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Steak-Rpc

版本 :1.0.0

技术栈 :Netty Zookeeper Kryo Spring

实现思想 :本rpc在服务端启动时候,获取标注有@LpService的类,表示此类是一个服务,需要注册到zk注册中心,此注解有group和version两个属性,group表示组,为了区分存在同名服务,version表示接口的版本,在zk注册中心根节点名称为lpRpc,是一个持久化节点,而子节点则是服务,是临时节点,当服务端关闭以后,相应的服务则会自动删除,服务名格式为,服service:group:version,如: UserService:business:1.0.0 ,服务节点存储类路径,远程服务地址,格式为:host:port:className,如 192.168.0.1:8080:com.lp.rpc.service.impl.UserServiceImpl ,服务端进行服务注册以后,客户端启动去zk注册中心拿到所有服务,然后存在本地缓存中,然后监听服务端服务的变化,实时更新本地缓存,调用服务时首先在本地缓存中查找是否存在服务,存在的话直接发起远程调用,不存在则去注册中心查找服务,客户端通过反射获取到类信息以后发起远程调用,然后经过序列化等一系列操作,最终返回调用结果。

说明 :此版本是第一个版本,比较简陋,后续会陆续进行更新 :kissing_heart:

调用示例: server

        <dependency>
            <groupId>com.lp</groupId>
            <artifactId>Lp-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.lp</groupId>
            <artifactId>Lp-registry</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        version和group不是必选,如果指定了,name客户端在发起请求的时候也需要指定,不然找不到服务

        @LpService(version = "1.0.0" , group = "business")
        public class HelloServiceImpl implements HelloService {
            @Override
            public String sayHello() {
                return "business group";
            }
        }
        public class LpServerBootstrap {
        public static void main(String[] args) {
              new ClassPathXmlApplicationContext("spring.xml");
            }
        }

client client端必须引入以下几个包,Lp-client客户端代理,Lp-registry服务发现,Lp-common一些依赖。

        <dependency>
            <groupId>com.lp</groupId>
            <artifactId>Lp-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.lp</groupId>
            <artifactId>Lp-registry</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.lp</groupId>
            <artifactId>Lp-client</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        public class LpClientBootstrap {
            public static void main(String[] args) throws NoSuchFieldException {
                ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
                HelloService helloService = LpClientProxy.createProxy(HelloService.class, "basic", "1.0.0");
                System.out.println(helloService.sayHello());
            }
        }

版本更新日志:

MIT License Copyright (c) 2021 steakliu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于netty,zookeeper,spring,kryo的轻量级rpc框架 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/steakliu/lp-rpc.git
git@gitee.com:steakliu/lp-rpc.git
steakliu
lp-rpc
rpc-framework
master

搜索帮助