mikong / hanbaiki Goto Github PK
View Code? Open in Web Editor NEWA simple key-value store written in Rust. It uses the Redis Serialization Protocol.
Home Page: https://mikong.github.io/hanbaiki
License: MIT License
A simple key-value store written in Rust. It uses the Redis Serialization Protocol.
Home Page: https://mikong.github.io/hanbaiki
License: MIT License
Environment: x86_64-apple-darwin
Target: x86_64-pc-windows-gnu
Note: Our target is x86_64-pc-windows-gnu instead of x86_64-pc-windows-msvc. The MSVC ABI is only needed if we want to interoperate with software produced by Visual Studio. It also requires Visual Studio or Visual C++ Build Tools.
We encounter the following error messages as described in rust-lang/rust#48272:
undefined reference to `__onexitend'
undefined reference to `__onexitbegin'
That issue in rust-lang/rust was closed after they added back the downloading of rust-mingw, but it doesn't help our case. We have our own MinGW and removing the linker from ~/.cargo/config will result in a linker error as described in rust-lang/rust#33465:
ld: unknown option: --enable-long-section-names
clang: error: linker command failed with exit code 1
To Reproduce
$ brew install mingw-w64
# Installs 6.0.0 as of writing
$ rustup target add x86_64-pc-windows-gnu
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
$ cargo build --target=x86_64-pc-windows-gnu
$ cargo build --release --target=x86_64-pc-windows-gnu
The initial implementation of message framing a bulk string data uses a simple state machine. However, a simple state machine isn't sufficient for handling array data. An array can have elements of any type including bulk strings and arrays. When reading more data from the TCP stream while trying to build an element of an array, the state machine should have a memory of where it is in the building of the array or sub-array so it can continue where it left off after completing an element.
Before we can implement the message framing of array data, we need to:
stream.read
loop outside of the functions for handling the individual types. Each function can just return Ok(None)
to indicate that it's not complete and needs more data to process the frame.When using redis-rb (redis gem 4.0.2), commands are not recognized:
irb(main):001:0> require 'redis'
=> true
irb(main):002:0> redis = Redis.new(host: "127.0.0.1", port: 6363)
=> #<Redis client v4.0.2 for redis://127.0.0.1:6363/0>
irb(main):003:0> redis.set("hello", "world")
Redis::CommandError: ERROR: Command not recognized
Debug output of command from redis-rb in hanbaiki server:
Array([BulkString("set"), BulkString("hello"), BulkString("world")])
We need to support lowercase commands to support client libraries.
Is your feature request related to a problem? Please describe.
Performance. The project currently uses the standard library HashMap. When the project becomes more stable and have a better set of benchmark tests, we should explore alternative data structures that might provide better performance.
Describe the solution you'd like
Use the im
crate and compare its performance with the standard library HashMap.
Describe alternatives you've considered
Alternatively, we can make smaller changes first, such as using a faster hashing algorithm for the standard library HashMap. We'll have to consider the security implications of using other hashing functions though.
Additional context
The Feature Request issue template was recently added to this project, and I thought of trying it out with a feature that I've listed in my internal notes for this project.
It is possible that a single stream.read
may receive not just the full message but also part or the whole of the next message. Message framing in the RESP reader should take this into account, making sure the current message won't include any part of the next message and processing the next message should still be able to start at the right part.
The RESP reader doesn't have any automated tests due to the TcpStream parameter in its functions.
I'm currently considering 3 options:
Use TcpStream argument in the test. This involves actually running a server and clients.
Use a mock stream struct that implements the Read trait. The function signatures will have to be changed to accept any type that implements Read.
Create a custom trait that a mock stream struct and TcpStream will implement. The function signatures will still need to be changed but it doesn't open it up to any Read type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.