GithubHelp home page GithubHelp logo

petehayes102 / selium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from seliumlabs/selium

0.0 1.0 0.0 453 KB

An extremely dev-friendly, composable messaging platform

Home Page: https://selium.com

License: Mozilla Public License 2.0

Python 0.09% Rust 99.91%

selium's Introduction

Selium

Crates.io MPL2 licensed Build Status Audit Status

Selium is an extremely developer friendly, composable messaging platform with zero build time configuration.

Getting Started

Hello World

First, create a new Cargo project:

$ cargo new --bin hello-selium
$ cd hello-selium
$ cargo add futures
$ cargo add -F std selium
$ cargo add -F macros,rt tokio

Copy the following code into hello-world/src/main.rs:

use futures::{SinkExt, StreamExt};
use selium::{prelude::*, std::codecs::StringCodec};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let connection = selium::client()
        .with_certificate_authority("certs/client/ca.der")? // your Selium cert authority
        .with_cert_and_key(
            "certs/client/localhost.der",
            "certs/client/localhost.key.der",
        )? // your client certificates
        .connect("127.0.0.1:7001") // your Selium server's address
        .await?;

    let mut publisher = connection
        .publisher("/some/topic") // choose a topic to group similar messages together
        .with_encoder(StringCodec) // allows you to exchange string messages between clients
        .open() // opens a new stream for sending data
        .await?;

    let mut subscriber = connection
        .subscriber("/some/topic") // subscribe to the publisher's topic
        .with_decoder(StringCodec) // use the same codec as the publisher
        .open() // opens a new stream for receiving data
        .await?;

    // Send a message and close the publisher
    publisher.send("Hello, world!".into()).await?;
    publisher.finish().await?;

    // Receive the message
    if let Some(Ok(message)) = subscriber.next().await {
        println!("Received message: {message}");
    }

    Ok(())
}

For the purpose of testing, developing Selium, or otherwise jumping straight into the action, you can use the selium-tools CLI to generate a set of self-signed certificates for use with mTLS.

To do so, install the selium-tools binary, and then run the gen-certs command. By default, gen-certs will output the certs to certs/client/* and certs/server/*. You can override these paths using the -s and -c arguments respectively.

$ cargo install selium-tools
$ cargo run --bin selium-tools gen-certs

Next, open a new terminal window and start a new Selium server, providing the certificates generated in the previous step.

$ cargo install selium-tools
$ cargo install selium-server
$ cargo run --bin selium-server -- \
  --bind-addr=127.0.0.1:7001 \
  --ca certs/server/ca.der \
  --cert certs/server/localhost.der \
  --key certs/server/localhost.key.der

Finally, in our original terminal window, run the client:

$ cargo run

Running Benchmarks

Included in the repository is a benchmarks binary containing end-to-end benchmarks for the publisher/subscriber clients.

These benchmarks measure the performance of both encoding/decoding message payloads on the client, as well the responsiveness of the Selium server.

To run the benchmarks with the default options, execute the following commands:

$ cd benchmarks
$ cargo run --release

This will run the benchmarks with default values provided for the benchmark configuration arguments, which should produce a summary similar to the following:

$ cargo run --release

Benchmark Results
---------------------
Number of Messages: 1,000,000
Number of Streams: 10
Message Size (Bytes): 32

| Duration             | Total Transferred    | Avg. Throughput      | Avg. Latency         |
| 1.3476 Secs          | 30.52 MB             | 22.65 MB/s           | 1347.56 ns           |

If the default configuration is not sufficient, execute the following command to see a list of benchmark arguments.

$ cargo run -- --help

Next Steps

Selium is a brokered messaging platform, meaning that it has a client and a server component. Check out the client and server crates for more details.

We also have the user guide that includes all of this information and much more. Our Getting Started chapters will step you through the process of setting up a secure, working Selium platform in 5 minutes or less.

Contributing to Selium

We'd love your help! If there's a feature you want, raise an issue first to avoid disappointment. While we're happy to merge contributions that are in line with our roadmap, your feature may not quite fit. Best to check first.

selium's People

Contributors

adenh93 avatar dependabot[bot] avatar ltuch avatar petehayes102 avatar

Watchers

 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.