#不可变 #分布式数据库 #异步 #事件总线 #NoSQL #加密 #数据库

bin+lib ate

具有强加密和身份验证的分布式不可变数据存储

46 个版本 (12 个稳定版)

1.3.0 2022年8月8日
1.2.1 2022年3月20日
1.1.0 2022年2月1日
1.0.2 2021年12月2日
0.2.2 2021年3月31日

260密码学 中排名

Download history 28/week @ 2024-03-11 27/week @ 2024-03-18 6/week @ 2024-03-25 38/week @ 2024-04-01 8/week @ 2024-04-08 5/week @ 2024-04-15 29/week @ 2024-04-22 39/week @ 2024-04-29 9/week @ 2024-05-13 35/week @ 2024-05-20 4/week @ 2024-05-27 29/week @ 2024-06-03 14/week @ 2024-06-10 6/week @ 2024-06-17 12/week @ 2024-06-24

每月下载量 61
6 crates 中使用

MIT/ApacheLGPL-3.0

1MB
31K SLoC

ATE

导航

什么是 ATE?

...它是一个 NoSQL 数据库吗?
...它是一个 分布式重做日志 吗?
...它是一个 事件总线 吗?
...它是一个 API 框架 吗?
...它是一个 分布式队列 吗?
...它是一个 分布式缓存 吗?
...它是一个安全加密的保险库吗?
...它是一个 量子抗性 通信框架吗?
...它是一个 WORM 存档解决方案吗?

ATE 是上述所有事物,但又不完全是;它是以独特方式与分布式数据交互的方式,可以轻松实现上述所有用例 - 查看如何实现它们的示例

为什么取名 ATE?

“mutate”这个词的起源是拉丁词“-ate”。
https://www.dictionary.com/browse/mutate

摘要

ATE 是一个分布式不可变数据存储,并具有基于内存的物化视图和强加密及身份验证。

这意味着什么?

这个库是现代分布式计算中处理数据的方式。

  • ...数据持久化到分布式提交日志。
  • ...分区被划分为链,将数据分片到物理域。
  • ...数据流到应用是按需发生的,正如应用需要时。
  • ...每个链都是一个加密图,具有不同节点上的唯一非对称密钥。
  • ...信任链的根通过各种插件验证加密。
  • ...强大的身份验证和授权按设计集成到数据模型中。
  • ...加密高度抵抗量子攻击并使用细粒度的租户密钥。
  • ...所有这些集成到一个无共享的、高度可移植的可执行文件中。

示例

项目

典型部署模式

     .-------------.          .- - - - - - -.
     |   Server    |              Server
     |             | .. .. .. |             | .. .. ..
     | >atedb solo |
     '------|----\-'          '- - - - - - -'
            |     \                 
        ws://yourserver.com/db
            |       \
     .------|------. \
     |Native Client|  .-----Browser-----.
     |             |  |.---------------.|
     | >program    |  || >wasm32-wasi  ||
     |  \ate.so    |  ||  \ate.wasm    ||
     '-------------'  |'---------------'|
                      '-----------------'

The easiest way to get up and running is to just build your app and point the
database URL at ws://wasmer.sh/db. You will need to register an account and verify
your identity however after this you can use the free databases and/or paid option.

Alternatively, if you wish to host your own ATE servers in infrastructure that you
manage and run then follow these high-level steps.

1. Server runs the 'atedb' process on some network reachable location
2. Create several records for each IP address under the same A-record in your DNS
3. Either create your own authentication server as well using the auth-server binary
   or just use the authentication servers hosted at Wasmer by pointing to
   ws://wasmer.sh/auth.

快速开始

Cargo.toml

[dependencies]
tokio = { version = "*", features = ["full", "signal", "process"] }
serde = { version = "*", features = ["derive"] }
ate = { version = "*" }
wasmer-auth = { version = "*" }

main.rs

use serde::{Serialize, Deserialize};
use wasmer_auth::prelude::*;

#[derive(Debug, Serialize, Deserialize, Clone)]
struct MyData
{
    pi: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>>
{
    let dio = DioBuilder::default()
        .with_session_prompt().await?
        .build("mychain")
        .await?;

    dio.store(MyData {
        pi: "3.14159265359".to_string(),
    })?;
    dio.commit().await?;

    Ok(())
}

变更日志

1.2.2  -= Code Refactoring =-
        + The crypto library has been split out from the main ATE library to reduce dependencies
          when using just cryptographic routines and to reduce build times.
1.2.1  -= Lazy Loading =-
        + Subscribing to chains can now load the data in the chain on demand as its needed
          which reduces the startup time considerably.
        + Temporal clients will default to lazy loading
        + Data loaded via the lazy loading mechanism will now be cached client side

1.1.1  -= Performance and Bug Fixes =-
        + Fixed an issue with the web sockets that caused sporadic disconnects
        + Improved the performance of web socket messages by reusing IV's
        + Reduced the message overhead with a new message encoding format

1.1.0  -= Comms Upgrade =-
        + Streaming websockets are now more stable as they use length headers to delimit messages.
        + Fixed a bug where disconnecting clients would drop neighbors on the same server.
        + Various changes to the interfaces for stability reasons
        (this upgrade is not backwards compatible with version 1.0.6)

1.0.6  -= Bug Fixes =-
        + Modified the interface slightly but most users should not be impacted
        + Fixed a bug around validators rejecting events during the subscribe
          process that re-reads them from disk - these validators should not be running
        + Added the ability to list all root objects
        + Added the ability to delete all root objects (and hence wipe a chain)
        + Fixed a serious deadlock situation when commiting transactions that was causing timeouts

1.0.2  -= WASM BUS =-
       + Integrated with the WASM bus (wasmer-bus) which allows for ATE to use
         the web sockets while running in a controlled sandbox.

1.0.0  -= Major Release =-
       + See [README.md](https://github.com/wasmerio/ate/blob/e0beedbbbd84f95cd6c7a9a45b8903058f65b6fd/README.md)

<=0.8.0 See commit history

高级设计

.--[ atedb  ]---. .--[ atedb  ]---.      .-[auth-server]-.
|               | |               |      |               |
|>local redo-log| |>local redo-log|      |>local redo-log|
|.-------------.| |.-------------.|      |.-------------.|
|| Chain     1 || ||             ||      ||    user     ||
||             || || Chain     2 ||      ||   account   ||
|*-------------*| |*------|------*|      |*-----|-------*|
|               |       subscribe             login      
|                \________|_____________________|____
|                         |                     |    
|  >local redo-log                                   
|  >Crypto-Graph Materiaized View< (in memory)       
|  .----------------------------------.      session 
|  |             root(hash)           |   .-----------.
|  |              |                   |   |  -token   |
|  |      dao----dao(aes)             |---|  -claims  |
|  |              \                   |   |  -keys    |
|  |               dao                |   *-----------*
|  |                                  |

功能标志

  • 'client' - 允许用户连接到 ATE 数据链并/或在本地上托管的客户端功能
  • 'server' - 在分布式模式下创建和运行 ATE 所需的服务器功能,数据在服务器节点上复制
  • 'client_web' - 为在浏览器沙盒中运行而设计的客户端功能 (--target=wasm32-wasi)

WebAssembly

当编译为 WASM 时,请使用以下命令

cargo build --target wasm32-wasi --no-default-features --features client_web

低级示例

Cargo.toml

[dependencies]
tokio = { version = "*", features = ["full", "signal", "process"] }
serde = { version = "*", features = ["derive"] }
ate = { version = "*" }

main.rs

use serde::{Serialize, Deserialize};
use ate::prelude::*;

#[derive(Clone, Serialize, Deserialize)]
struct World
{
    commandment: String
}

#[tokio::main]
async fn main() -> Result<(), AteError>
{
    // The default configuration will store the redo log locally in the temporary folder
    let conf = AteConfig::default();
    let builder = ChainBuilder::new(&conf).await.build();

    // We create a chain with a specific key (this is used for the file name it creates)
    let chain = builder.open(&ChainKey::from("universe")).await?;
    
    // We interact with the data stored in the chain-of-trust using a DIO
    let session = AteSession::default();
    let mut dio = chain.dio(&session).await;
    
    // In this example we store some data in the "World" object
    let key = dio.store(World {
        commandment: "Hello".to_string(),
    })?.key().clone();
    dio.commit().await?;
    
    // Now we retreive the data and print it to console
    println!("{} world!", dio.load::<World>(&key).await?.commandment);

    // All errors in ATE will convert into the AteError
    Ok(())
}

贡献

如果您想帮助建立一个社区以继续开发此项目,请通过 [email protected] 联系我

依赖项

~16–30MB
~485K SLoC