Skip to content

kilyanni/rust-lib-reimpls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Groupchat

Originally this was going to simply be a simple chat-server with minimal dependencies, but I wanted to learn more about how serde and async executors (such as tokio) work internally, so I made basic implementations of both.

This repo features two main crates; serdy, a small reimplementation of serde and exec, a small async executor.

Project Structure

Notable (non-exhaustive) directories and files:

  • groupchat/src/bin/: Contains the executable targets
    • thread_server.rs: A thread-per-connection server implementation
    • async_server.rs: An async server implementation, using mio for I/O. Nearly identical to thread_server.rs, but with async I/O
    • event_server.rs: An event-driven server implementation
    • client.rs: The chat client implementation
  • groupchat/src/fmt/: Custom binary format implementation for efficient message serialization
    • framed.rs: Message framing implementation
  • exec/: Contains a basic work-stealing multithreaded executor implementation
    • mio.rs: A mio-based async I/O implementation for use with the executor
    • async_ch.rs Basic async channel implementations
  • serdy/: Core serialization framework (similar to serde)
  • serdy-derive/: Procedural macros for deriving serialization implementations

Quick Start

  1. Start a server (choose one):

    # Thread-per-connection server
    cargo run --bin thread_server
    
    # OR Event-driven server
    cargo run --bin event_server
  2. Connect with one or more clients:

    cargo run --bin client

The server will listen for incoming connections, and clients can send messages that will be broadcast to all connected clients.

See module documentation for more information.

Documentation

To view the full documentation with detailed explanations of the APIs and implementations, run:

cargo doc --open

This will build and open the documentation in your default web browser.

Notes

This project was developed as a learning exercises. At some points, there are some easy speed-ups left on the table because they weren't particularly interesting to implement. For example, instead of a custom lockless channel implementation, a simple mutex-guarded VecDequeue does the same job, just slower. Similarly, the IO-loop is a busy loop in a separate thread, rather than a tokio-esque reactor that gets ran by the workers when they're free.

About

Basic reimplementation of serde and a work-stealing async executor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages