Skip to content

mahler50/RPC-Framework

Repository files navigation

瓜子RPC框架

项目介绍

基于Java、Vert.x、ETCD实现的高性能RPC框架。支持多种序列化器、注册中心、负载均衡、重试和容错机制。采用注解驱动设计,方便SpringBoot开发者使用。

使用说明

本框架支持SpringBoot开发者使用注解来使用RPC框架。

@SpringBootApplication
@EnableRpc
public class ExampleSpringbootProviderApplication {

    public static void main(String[] args) {
        SpringApplication.run(ExampleSpringbootProviderApplication.class, args);
    }

}

使用@EnableRpc即可在项目启动时初始化框架

@Service
@RpcService
public class UserServiceImpl implements UserService{


    @Override
    public User getUser(User user) {
        System.out.println("用户名:" + user.getName());
        return user;
    }
}

使用@RpcService即可将服务实现类注册为RPC服务

@Service
public class ExampleServiceImpl {

    @RpcReference
    private UserService userService;

    public void test() {
        User user = new User();
        user.setName("kunkun");
        User resultUser = userService.getUser(user);
        System.out.println(resultUser.getName());
    }
}

服务调用法使用@RpcReference在服务接口类上即可注入RPC服务实现类。

项目支持.propertiesyml/yaml配置文件来对RPC框架进行配置,且兼容SpringBootapplication.yml文件

spring:
  application:
    name: guazi-rpc-consumer
rpc:
  name: guazi-rpc
  serverHost: localhost
  serverPort: 9999
  version: 1.0.0
  mock: false
  serializer: hessian
  loadBalancer: roundRobin
  retryStrategy: fixedInterval
  tolerantStrategy: failFast
  registryConfig:
    registry: etcd
    address: http://localhost:2380

About

A RPC Framework written in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages