Git Product home page Git Product logo

turbo-rpc's Introduction

turbo-rpc

turbo-rpc 是一款速度超凡的异步响应式RPC框架

功能特点

  • 仅支持异步调用, Service 接口所有 public 方法返回值都必须为 CompletableFuture
  • 配置定义在 Service 接口上, 而非实现类上, 方法实现者和调用者都不需要引入奇奇怪怪的注解
  • 支持 REST 调用
  • 支持失败回退, 支持熔断, 支持心跳, 支持自动重连
  • 支持自定义 服务注册 负载均衡 序列化
  • 支持 Filter, 可通过该机制实现 Tracing 限流限速 黑白名单 等功能
  • 支持 spring boot

Quick Start

Maven依赖:

<!-- 必须引入 -->
<dependency>
    <groupId>com.turbo-rpc</groupId>
    <artifactId>turbo-rpc</artifactId>
    <version>0.0.9</version>
</dependency>

<!-- 序列化方式,kryo protostuff 两个中任选一个 -->
<dependency>
    <groupId>com.turbo-rpc</groupId>
    <artifactId>turbo-kryo</artifactId>
    <version>0.0.9</version>
</dependency>

<!-- 序列化方式,kryo protostuff 两个中任选一个 -->
<dependency>
    <groupId>com.turbo-rpc</groupId>
    <artifactId>turbo-protostuff</artifactId>
    <version>0.0.9</version>
</dependency>

<!-- zk注册中心,可选引入 -->
<dependency>
    <groupId>com.turbo-rpc</groupId>
    <artifactId>turbo-register-zk</artifactId>
    <version>0.0.9</version>
</dependency>

<!-- SpringBoot集成,可选引入 -->
<dependency>
    <groupId>com.turbo-rpc</groupId>
    <artifactId>turbo-spring-boot-starter</artifactId>
    <version>0.0.9</version>
</dependency>

1.定义接口

@TurboService(version = "1.0.0")
public interface HelloService {

	@TurboService(version = "1.0.0", rest = "hello")
	default CompletableFuture<String> hello(String msg) {
		// default实现会自动注册为失败回退方法,当远程调用失败时执行
		return CompletableFuture.completedFuture("error");
	}
}

2.服务端实现接口

@Component
public class HelloServiceImpl implements HelloService {
	@Override
	public CompletableFuture<String> hello(String msg) {
		return CompletableFuture.completedFuture(msg);
	}
}

3.配置turbo-server.conf, 声明 服务器地址 序列化协议 注册地址 等信息

4.服务端启动

@SpringBootApplication(scanBasePackages = { "com.hello" })
@EnableTurboServer
public class TruboServerBootTest {
	public static void main(String[] args) {
		SpringApplication.run(TruboServerBootTest.class, args);
	}
}

5.客户端调用

@Component
public class HelloReferTest {
	@Autowired
	HelloService helloService;

	public void doSomeThing(String msg) {
		helloService.hello(msg)
			.thenAccept(message -> System.out.println(message));
	}
}

6.配置turbo-client.conf, 声明 服务器地址 序列化协议 注册地址 等信息

7.客户端启动

@SpringBootApplication(scanBasePackages = { "com.hello" })
@EnableTurboClient
public class HelloBootTest {
	public static void main(String[] args) {
		SpringApplication.run(HelloBootTest.class, args);
	}
}

turbo 技术原理

turbo-rpc's People

Contributors

hank-whu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.