#http #database #web #redis #mq

tardis

Elegant, clean Rust development framework

2 releases

Uses new Rust 2021

0.1.0-alpha9 Jun 9, 2022
0.1.0-alpha8 Apr 5, 2022
0.1.0-alpha6 Mar 7, 2022
0.1.0-alpha4 Feb 24, 2022
0.1.0-alpha11 Jun 16, 2022

#160 in Web programming

Download history 24/week @ 2022-04-27 22/week @ 2022-05-04 31/week @ 2022-05-11 10/week @ 2022-05-18 18/week @ 2022-05-25 32/week @ 2022-06-01 58/week @ 2022-06-08 32/week @ 2022-06-15 4/week @ 2022-06-22 62/week @ 2022-06-29 44/week @ 2022-07-06 22/week @ 2022-07-13 59/week @ 2022-07-20 63/week @ 2022-07-27 3/week @ 2022-08-03

147 downloads per month

MIT license

280KB
4.5K SLoC

`Preview version, will not guarantee the stability of the API! Do NOT use in production environment!


Elegant, Clean Rust development framework🛸


Crate Docs Build Status Test Coverage License

TARDIS([tɑːrdɪs] "Time And Relative Dimension In Space") From "Doctor Who".

💖 Core functions

  • Relational database client for MySQL, PostgresSQL
  • Web service and web client for OpenAPI v3.x
  • Distributed cache client for Redis protocol
  • RabbitMQ client for AMQP protocol
  • Search client for Elasticsearch
  • Mail client for SMTP protocol
  • Object Storage client for arbitrary S3 compatible APIs
  • Mainstream encryption algorithms and SM2/3/4 algorithms
  • Containerized unit testing of mainstream middleware
  • Multi-environment configuration
  • Multi-application aggregation
  • Configure encryption support
  • Internationalization and localization support
  • Commonly used operations (E.g. uniform error handling, encryption and decryption, regular checksums)

⚙️Feature description

  • trace tracing operation
  • crypto encryption, decryption and digest operations
  • future asynchronous operations
  • reldb relational database operations(based on SeaORM)
  • web-server web service operations(based on Poem)
  • web-client web client operations
  • cache cache operations
  • mq message queue operations
  • mail mail send operations
  • os object Storage operations
  • test unit test operations

🚀 Quick start

The core operations of the framework all use TardisFuns as an entry point. E.g.

TardisFuns::init(relative_path)      // Initialize the configuration
TardisFuns::field.x                  // Some field operations
TardisFuns::reldb().x                // Some relational database operations
TardisFuns::web_server().x           // Some web service operations

Web service example

Dependency Configuration

[dependencies]
tardis = { version = "^0", features = ["web-server"] }

Processor Configuration

use tardis::basic::error::TardisError;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::param::Query;
use tardis::web::web_resp::{TardisApiResult, TardisResp};

pub struct Api;

#[poem_openapi::OpenApi]
impl Api {
    #[oai(path = "/hello", method = "get")]
    async fn index(&self, name: Query<Option<String>>) -> TardisResult<String> {
        match name.0 {
            Some(name) => TardisResp::ok(format!("hello, {}!", name)),
            None => TardisResp::err(TardisError::NotFound("name does not exist".to_string())),
        }
    }
}

Startup class configuration

use tardis::basic::result::TardisResult;
use tardis::tokio;
use tardis::TardisFuns;
use crate::processor::Api;
mod processor;

#[tokio::main]
async fn main() -> TardisResult<()> {
    // Initial configuration
    TardisFuns::init("config").await?;
    // Register the processor and start the web service
    TardisFuns::web_server().add_module("", Api).start().await
}

More examples

|-- examples
  |-- reldb         Relational database usage example
  |-- web-basic     Web service Usage Example
  |-- web-client    Web client Usage Example
  |-- webscoket     WebSocket Usage Example
  |-- cache         Cache Usage Example
  |-- mq            Message Queue Usage Example
  |-- todos         A complete project usage example
  |-- multi-apps    Multi-application aggregation example
  |-- perf-test     Performance test case

FAQ

  • An failed to run custom build command for openssl-sys error occurs when running under Windows.The solution is as follows( @see https://github.com/sfackler/rust-openssl/issues/1062 ):
    git clone https://github.com/Microsoft/vcpkg --depth=1
    cd vcpkg
    bootstrap-vcpkg.bat
    vcpkg.exe integrate install
    vcpkg.exe install openssl:x64-windows-static
    set OPENSSL_NO_VENDOR=1
    set OPENSSL_DIR=<Current Dir>\packages\openssl_x64-windows-static
    

Thanks to Jetbrains for the Open Source License

Dependencies

~7–23MB
~481K SLoC