All Projects → tonivade → resp-server

tonivade / resp-server

Licence: MIT license
Netty implementation of REdis Serialization Protocol, and a simple framework to implement command based protocols

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to resp-server

qynat-spring-boot-starter
A springboot-starter that can achieve Intranet penetration. 一款可以实现内网穿透的springboot-starter。
Stars: ✭ 65 (+62.5%)
Mutual labels:  netty
itstack-naive-chat-server
💞 《服务端》| 服务端同样使用Netty4.x作为socket的通信框架,同时在服务端使用Layui作为管理后台的页面,并且我们的服务端采用偏向于DDD领域驱动设计的方式与Netty集合,以此来达到我们的框架结构整洁干净易于扩展。同时我们的通信协议也是在服务端进行定义的,并对外提供可引入的Jar包,这样来保证客户端与服务端共同协议下进行通信。
Stars: ✭ 21 (-47.5%)
Mutual labels:  netty
aquiver
🚀 The aquifer is a java web framework based on Java8 and netty
Stars: ✭ 38 (-5%)
Mutual labels:  netty
mmqtt
An Open-Source, Distributed MQTT Broker for IoT.
Stars: ✭ 58 (+45%)
Mutual labels:  netty
scamper-chat
An IRC-like chat client and server using SCTP, based on Scamper+Netty
Stars: ✭ 13 (-67.5%)
Mutual labels:  netty
distributed-id
基于netty4+twitter-snowFlake分布式Id生成之服务实现
Stars: ✭ 18 (-55%)
Mutual labels:  netty
fastim
🚀基于Netty高可用分布式即时通讯系统,支持长连接网关管理、单聊、群聊、离线消息、消息推送消息、消息已读未读、消息未读数、红包、消息漫游等功能,支持集群部署的分布式架构。
Stars: ✭ 111 (+177.5%)
Mutual labels:  netty
read
学习笔记 dubbo,rocketmq 源码解析
Stars: ✭ 33 (-17.5%)
Mutual labels:  netty
vertx-mail-client
No description or website provided.
Stars: ✭ 30 (-25%)
Mutual labels:  netty
LunarGdx
A networking library for LibGDX utilizing Netty allowing easy creation of multiplayer games.
Stars: ✭ 23 (-42.5%)
Mutual labels:  netty
device-simulator
基于netty的设备模拟器,模拟设备消息收发,压力测试。
Stars: ✭ 35 (-12.5%)
Mutual labels:  netty
netty-in-action-cn
Netty In Action 中文版
Stars: ✭ 1,389 (+3372.5%)
Mutual labels:  netty
bbs
基于spring boot的java论坛系统
Stars: ✭ 186 (+365%)
Mutual labels:  netty
zrp
zrp 是使用Java开发的一款基于Netty的内网穿透工具,主要用于将内网服务反向代理到公网访问。目前支持所有TCP上层协议的代理,包括但不限于HTTP、SSH、FTP、TELNET、SMTP、POP3、DNS等。
Stars: ✭ 32 (-20%)
Mutual labels:  netty
Spiky-Project
Unreal Engine MMO game and server example built on Netty
Stars: ✭ 73 (+82.5%)
Mutual labels:  netty
sample-spring-webflux
testing webclient reactive communication with spring boot reactive application built on top of spring webflux
Stars: ✭ 21 (-47.5%)
Mutual labels:  netty
mini-rpc
Spring + Netty + Protostuff + ZooKeeper 实现了一个轻量级 RPC 框架,使用 Spring 提供依赖注入与参数配置,使用 Netty 实现 NIO 方式的数据传输,使用 Protostuff 实现对象序列化,使用 ZooKeeper 实现服务注册与发现。使用该框架,可将服务部署到分布式环境中的任意节点上,客户端通过远程接口来调用服务端的具体实现,让服务端与客户端的开发完全分离,为实现大规模分布式应用提供了基础支持
Stars: ✭ 221 (+452.5%)
Mutual labels:  netty
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (+145%)
Mutual labels:  netty
im-bass
基础IM通信
Stars: ✭ 56 (+40%)
Mutual labels:  netty
bootpush
📶即时消息推送服务(即时通讯),基于Netty- Instant Messaging push service based on Netty
Stars: ✭ 146 (+265%)
Mutual labels:  netty

resp-server

Netty implementation of REdis Serialization Protocol, and a simple framework to implement command based protocols.

Why?

I love REDIS, IMHO is one of the best pieces of code ever made. Is fast, small and easy. One of the things I love of REDIS is the RESP protocol, and I think that it would be nice to build a library to implement services using this protocol. I have to say that this piece of code is based in another project I'm working ClauDB.

What?

RESP is the protocol used by REDIS, but it can be used to implement other client-server protocols.

It's nice because:

  • Is easy
  • Is fast
  • Also is human readable

RESP can serialize some data types

  • simple strings: +PONG\r\n
  • errors: -ERROR\r\n
  • integers: :1\r\n
  • bulk strings (binary-safe): $4\r\nPING\r\n
  • arrays: *3\r\n:1\r\n:2\r\n:3\r\n

What binary safe means? It means that can be what ever you want, a UTF-8 String or compressed data, a picture, etc...

Arrays can hold any data types inside, also other arrays.

And use \r\n as delimiter, that means you can open a telnet/netcat/nc against the server port and send whatever you want.

So, what provide this project in addition to the protocol implementation? Well, it defines a framework to implement command oriented protocols.

You only need to define a set of commands and implement them.

Some commands are built-in, ping, echo, time and quit.

What is a command?

A command is an array of bulk string in RESP, first element in array is the command, and the additional elements are the parameters of the command. This is how a command looks like:

    *2\r\n
    $4\r\n
    ECHO\r\n
    $13\r\n
    Hello World!\r\n

In this sample, ECHO is the command and Hello world! is the parameter.

How is implemented?

The protocol is implemented in Java8, using asynchronous IO (netty), and using the reactive programming paradigm (rxjava). What that means? It means that is single thread, every request is managed inside the same thread, so there's no concurrency issues at all, the same way as REDIS works.

How can I use it?

It's very easy, you only need 2 lines of code to start the server

    RespServer server = RespServer.builder()
      .host("localhost").port(12345).commands(new CommandSuite()).build();
    server.start();

CommandSuite is the default commands suite but you can extend and add your own commands, well, that's the point :)

What a command looks like?

    @Command("ping")
    public class PingCommand implements RespCommand {
        @Override
        public RedisToken execute(Request request) {
            return RedisToken.status("PONG");
        }
    }

A command must implement the interface RespCommand. This interface only defines the method execute, who receives a Request object and returns a RedisToken.

You can get the parameter of the command like this

    SafeString param0 = request.getParam(0);

Every parameter is a SafeString, and what the hell is a SafeString? Previously, we said that RESP is binary-safe, so, it means that you can receive anything. SafeString wraps the bytes received, but, don't worry, it's not going to be a problem, trust me.

And you can response to a request this way:

    return RedisToken.status("PONG");

You have similar methods like array, integer, string, error...

Annotations are used to define some metadata to the commands, @Command annotation defines the command name, also there's another annotation, @ParamLength to define the number of the parameter accepted for this command

    @Command("echo")
    @ParamLength(1)
    public class EchoCommand implements RespCommand {
        @Override
        public RedisToken execute(Request request) {
            return RedisToken.string(request.getParam(0));
        }
    }

If the number of parameters is less than the especified value, the command is rejected with an error.

Maven

<dependency>
    <groupId>com.github.tonivade</groupId>
    <artifactId>resp-server</artifactId>
    <version>0.19.0</version>
</dependency>

Gradle

compile 'com.github.tonivade:resp-server:0.19.0'

Stargazers over time

Stargazers over time

Continuous Integration

Build Status Codacy Badge Codacy Coverage

LICENSE

This project is released under MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].