微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

turbo-rpc 异步响应式 RPC 框架

程序名称:turbo-rpc

授权协议: Apache-2.0

操作系统: 跨平台

开发语言: Java

turbo-rpc 介绍

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

功能特点

Quick Start

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-rpc 官网

https://gitee.com/hank-whu/turbo-rpc

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐