https://github.com/bytedance/ipmb

An interprocess message bus system built in Rust.

https://github.com/bytedance/ipmb

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.4%) to scientific vocabulary

Keywords

cpp ipc message-bus nodejs rust
Last synced: 5 months ago · JSON representation

Repository

An interprocess message bus system built in Rust.

Basic Info
  • Host: GitHub
  • Owner: bytedance
  • License: apache-2.0
  • Language: Rust
  • Default Branch: main
  • Homepage:
  • Size: 291 KB
Statistics
  • Stars: 108
  • Watchers: 7
  • Forks: 14
  • Open Issues: 1
  • Releases: 17
Topics
cpp ipc message-bus nodejs rust
Created over 2 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

An interprocess message bus system built in Rust, which can be used to pass messages between multiple processes, even including kernel objects (HANDLE/MachPort/FD).

Crates.io npm version

Goals

  • Easy to use: join, send, recv, that's everything
  • Bus architecture: No server or client, messages can be freely transmitted among multiple endpoints
  • Message typing: An endpoint can send or receive multiple message types simultaneously without all endpoints defining a complete global message structure
  • Practical features: Object, Memory Region, Selector and so on

Getting Started

toml [dependencies] ipmb = "0.8"

earth.rs: ```rust use ipmb::label;

fn main () -> Result<(), Box> { // Join your bus let options = ipmb::Options::new("com.solar", label!("earth"), ""); let (sender, receiver) = ipmb::join::(options, None)?;

// Receive messages
while let Ok(message) = receiver.recv(None) {
    log::info!("received: {}", message.payload);
}
Ok(())

} ```

moon.rs: ```rust use ipmb::label; use std::thread; use std::time::Duration;

fn main () -> Result<(), Box> { // Join your bus let options = ipmb::Options::new("com.solar", label!("moon"), ""); let (sender, receiver) = ipmb::join::(options, None)?;

loop {
    // Create a message
    let selector = ipmb::Selector::unicast("earth");
    let mut message = ipmb::Message::new(selector, "hello world".to_string());

    // Send the message
    sender.send(message)?;

    thread::sleep(Duration::from_secs(1));
}

} ```

Concepts

Identifier

An identifier is a system-level unique name for a bus, and only endpoints on the same bus can communicate with each other. On macOS, it will be used to register the MachPort service, on Windows, it will be used to create the corresponding named pipe, and on Linux, it will be used to bind abstract socket address.

Label

Label is the description of an endpoint, and a message can be routed to an endpoint with a LabelOp. A label can contain multiple elements, such as label!("renderer", "codec").

Selector

Selector is used to describe the routing rules of the message, which consists of 2 parts:

  1. SelectorMode: Specify how to consume the message when multiple endpoints satisfy routing rules at the same time.
    • Unicast: Only one endpoint can consume this message
    • Multicast: All endpoints can consume this message
  2. LabelOp: Describe the matching rules of label, and supports logical operations of AND/OR/NOT.

Payload

Payload is the body content of a message, and its type can be specified by the type parameter of the join function. You can define your own message types:

toml [dependencies] type-uuid = "0.1.2"

```rust use serde::{Deserialize, Serialize}; use type_uuid::TypeUuid;

[derive(Debug, Serialize, Deserialize, TypeUuid)]

[uuid = "7b07473e-9659-4d47-a502-8245d71c0078"]

struct MyMessage { foo: i32, bar: bool, }

fn main() -> Result<(), Box> { let (sender, receiver) = ipmb::join::(..)?; Ok(()) } ```

MessageBox

MessageBox is a container for multiple message types, allowing endpoints to send/receive multiple message types.

```rust use ipmb::MessageBox;

[derive(MessageBox)]

enum MultipleMessage { String(String), I32(i32), MyMessage(MyMessage), }

fn main() -> Result<(), Box> { let (sender, receiver) = ipmb::join::(..)?; Ok(()) } ```

Object

Object is the kernel object representation, MachPort on macOS, HANDLE on Windows, FD on Linux, ipmb supports sending Object as message attachment to other endpoints.

rust fn main () { let mut message = ipmb::Message::new(..); let obj = unsafe { ipmb::Object::from_raw(libc::mach_task_self()) }; message.objects.push(obj); }

MemoryRegion

MemoryRegion is a shared memory block, ipmb supports sending MemoryRegion as message attachment to other endpoints without copying.

rust fn main() -> Result<(), Box<dyn Error>>{ let mut message = ipmb::Message::new(..); let mut region = ipmb::MemoryRegion::new(16 << 10); let view = region.map(..)?; writeln!(view, "Hello")?; message.memory_regions.push(region); Ok(()) }

MemoryRegistry

Efficiently performs many MemoryRegions allocation by sharing and reusing MemoryRegions.

rust fn main() { let mut registry = ipmb::MemoryRegistry::default(); // Alloc memory region from the registry let mut region = registry.alloc(8 << 20, None); }

Language Bindings

  1. C/C++: ipmb-ffi provides ipmb_ffi.h/ipmb.h, prebuilt libraries can be downloaded here
  2. Node.js: ipmb-js provides node package (npm version)

Supported Platforms

| Platform | | |----------|-----| | macOS | ✅ | | Windows | ✅ | | Linux | ✅ |

Benchmark

Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, macOS 13.4

[2023-06-29T08:54:48Z INFO bench] 16 B 752,469/s 12.0 MB/s [2023-06-29T08:54:48Z INFO bench] 64 B 437,096/s 28.0 MB/s [2023-06-29T08:54:48Z INFO bench] 1.0 KB 412,224/s 422.1 MB/s [2023-06-29T08:54:48Z INFO bench] 4.1 KB 327,748/s 1.3 GB/s [2023-06-29T08:54:49Z INFO bench] 16.4 KB 33,261/s 544.9 MB/s

License

ipmb is dual-licensed:

Owner

  • Name: Bytedance Inc.
  • Login: bytedance
  • Kind: organization
  • Location: Singapore

GitHub Events

Total
  • Create event: 3
  • Release event: 1
  • Issues event: 3
  • Watch event: 41
  • Issue comment event: 4
  • Push event: 24
  • Fork event: 5
Last Year
  • Create event: 3
  • Release event: 1
  • Issues event: 3
  • Watch event: 41
  • Issue comment event: 4
  • Push event: 24
  • Fork event: 5

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 89
  • Total Committers: 1
  • Avg Commits per committer: 89.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 37
  • Committers: 1
  • Avg Commits per committer: 37.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Xiaopeng Li l****k@b****m 89
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 6
  • Total pull requests: 3
  • Average time to close issues: 14 days
  • Average time to close pull requests: about 7 hours
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.33
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 2
  • Average time to close issues: about 5 hours
  • Average time to close pull requests: about 2 hours
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 1.67
  • Average comments per pull request: 0.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • wangjia184 (3)
  • ksdhyPro (1)
  • nicolaspernoud (1)
  • sofoxe1 (1)
Pull Request Authors
  • xiaopengli89 (3)
  • wangjia184 (1)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cargo 13,411 total
    • npm 57 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 34
  • Total maintainers: 2
npmjs.org: ipmb-js

ipmb-js

  • Versions: 20
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 57 Last month
Rankings
Downloads: 8.9%
Stargazers count: 11.8%
Forks count: 15.9%
Average: 25.6%
Dependent repos count: 37.5%
Dependent packages count: 54.0%
Maintainers (1)
Last synced: 6 months ago
crates.io: ipmb-derive

ipmb-derive

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 3,341 Total
Rankings
Dependent repos count: 28.5%
Dependent packages count: 32.5%
Average: 53.1%
Downloads: 98.4%
Maintainers (1)
Last synced: 6 months ago
crates.io: ipmb

Inter-process message bus

  • Documentation: https://docs.rs/ipmb/
  • License: Apache-2.0 OR MIT
  • Latest release: 0.8.3
    published 7 months ago
  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 10,070 Total
Rankings
Dependent repos count: 28.5%
Dependent packages count: 32.5%
Average: 53.3%
Downloads: 98.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

Cargo.lock cargo
  • 110 dependencies
ipmb/Cargo.toml cargo
  • bytesize 1.1.0 development
  • env_logger 0.10.0 development
  • num-format 0.4.0 development
  • bincode 2.0.0-rc.3
  • log 0.4.17
  • once_cell 1.17.1
  • rand 0.8.5
  • serde 1.0.137
  • serde_bytes 0.11.7
  • smallvec 1.9.0
  • smol_str 0.1.23
  • thiserror 1.0.31
  • type-uuid 0.1.2
  • uuid 1.1.2
.github/workflows/dist-ffi.yml actions
  • Swatinem/rust-cache v2 composite
  • actions/checkout v3 composite
  • hustcer/setup-nu v3 composite
  • softprops/action-gh-release v1 composite
.github/workflows/dist-js.yml actions
  • Swatinem/rust-cache v2 composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/upload-artifact v3 composite
  • hustcer/setup-nu v3 composite
  • softprops/action-gh-release v1 composite
.github/workflows/test.yml actions
  • Swatinem/rust-cache v2 composite
  • actions/checkout v3 composite
  • hustcer/setup-nu v3 composite
Cargo.toml cargo
ipmb-derive/Cargo.toml cargo
ipmb-ffi/Cargo.toml cargo
ipmb-js/Cargo.toml cargo
ipmb-js/package.json npm