Giter Club home page Giter Club logo

gun-rs's Introduction

Gun-rs

Pure Rust implementation of Gun.js. For a wasm version, check out gun-rs-wasm.

Deployed at https://gun-rs.iris.to (serves iris-messenger at the root)

Live stats: https://gun-rs.iris.to/stats

Why?

  • Rust can be compiled into high-performing native binaries on many platforms, including embedded systems.
  • Maintaining and contributing to the codebase is easier than in Gun.js. Gun.js doesn't have compilation or minification steps, and the code is kind of manually minified ๐Ÿ˜„

Use

Install Rust first.

Gun relay

cargo install gundb
gundb start

Gun library

use gundb::{Node, NodeConfig};
use gundb::types::GunValue;
let mut db = Node::new_with_config(NodeConfig {
    outgoing_websocket_peers: vec!["wss://some-server-to-sync.with/gun".to_string()],
    ..NodeConfig::default()
});
let mut sub = db.get("greeting").on();
db.get("greeting").put("Hello World!".into());
if let GunValue::Text(str) = sub.recv().await.unwrap() {
    assert_eq!(&str, "Hello World!");
}

Status

3/12/2021:

  • Gun basic API
  • CLI for running the server
  • Incoming websockets
  • Outgoing websockets (env PEERS=wss://some-server-url.herokuapp.com/gun)
  • Multicast (Iris messages seem not to propagate โ€” size limit?)
  • In-memory storage
  • TLS support (env CERT_PATH and KEY_PATH)
  • Advanced deduplication of sync messages
  • Publish & subscribe
  • Disk storage
  • SEA (verification of signed data)

Issues

  • When multiple adapters are enabled, it sometimes gets stuck
  • User-space nodes (js: gun.user().get('something')) are relayed, but not properly retrieved and sent from memory (wrong format somehow)
  • Multicast doesn't relay large messages like Iris posts

Develop

cargo install cargo-watch
RUST_LOG=debug cargo watch -x 'run -- start'

Run on Heroku

heroku create --buildpack emk/rust
git push heroku master

or:

Deploy

gun-rs's People

Contributors

mmalmi avatar esomore avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.