com.github.sd4324530:fastrpc

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Лицензия

Лицензия

Группа

Группа

com.github.sd4324530
Идентификатор

Идентификатор

fastrpc
Последняя версия

Последняя версия

0.1
Дата

Дата

Тип

Тип

pom
Описание

Описание

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Система контроля версий

Система контроля версий

https://github.com/sd4324530/fastrpc.git

Скачать fastrpc

Имя Файла Размер
fastrpc-0.1.pom 8 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.sd4324530/fastrpc/ -->
<dependency>
    <groupId>com.github.sd4324530</groupId>
    <artifactId>fastrpc</artifactId>
    <version>0.1</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.sd4324530/fastrpc/
implementation 'com.github.sd4324530:fastrpc:0.1'
// https://jarcasting.com/artifacts/com.github.sd4324530/fastrpc/
implementation ("com.github.sd4324530:fastrpc:0.1")
'com.github.sd4324530:fastrpc:pom:0.1'
<dependency org="com.github.sd4324530" name="fastrpc" rev="0.1">
  <artifact name="fastrpc" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.sd4324530', module='fastrpc', version='0.1')
)
libraryDependencies += "com.github.sd4324530" % "fastrpc" % "0.1"
[com.github.sd4324530/fastrpc "0.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

  • fastrpc-core
  • fastrpc-server
  • fastrpc-client

fastrpc

基于java AIO实现的RPC调用框架

RPC服务端初始化

public static void main(String[] args) throws Exception {
        new FastRpcServer()
                .threadSize(20)
                .register("test", new TestService())
                .bind(4567)
                .start();
    }
public class TestService implements ITestService {

    private final Logger log = LoggerFactory.getLogger(getClass());

    @Override
    public String say(String what) {
        String result = "say " + what;
        log.debug(result);
        return result;
    }

    @Override
    public String name() {
        log.debug("call name");
        return "call name";
    }

    @Override
    public void ok(String ok) {
        log.debug("call ok");
        log.debug("param:{}", ok);
    }

    @Override
    public void none() {
        log.debug("call none");
    }

    @Override
    public User doUser(User user) {
        log.debug("收到user:" + user);
        user.setAge(user.getAge() - 1);
        user.setName("hello " + user.getName());
        user.setSex(!user.isSex());
        return user;
    }
}

RPC客户端初始化

public static void main(String[] args) {
        try(IClient client = new FastRpcClient()) {
            client.connect(new InetSocketAddress("127.0.0.1", 4567));
            ITestService service = client.getService("test", ITestService.class);
            String say = service.say("Hello!");
            System.out.println(say);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public interface ITestService {

    String say(String what);

    String name();

    void ok(String ok);

    void none();

    User doUser(User user);
}

Maven 项目引入

<dependency>
    <groupId>com.github.sd4324530</groupId>
    <artifactId>fastrpc-server</artifactId>
    <version>0.1</version>
</dependency>

<dependency>
    <groupId>com.github.sd4324530</groupId>
    <artifactId>fastrpc-client</artifactId>
    <version>0.1</version>
</dependency>

Версии библиотеки

Версия
0.1