The Push-CDN is a distributed and fault tolerant messaging system purpose-built to support peer-to-peer networks.
- Fast, reliable, and efficient
- Support for both publish-subscribe and direct messaging models
- First class support for routing and authentication on top of public-key cryptosystems
Broker
: The discrete message-passing unit of the system.Marshal
: Deals with user authentication and load balancingRedis
: Used as a consistent core for authentication states and broker discovery
#[tokio::main]
async fn main() {
// Generate a random keypair
let (private_key, public_key) =
BLS::key_gen(&(), &mut StdRng::from_entropy()).unwrap();
// Build the config, the endpoint being where we expect the marshal to be
let config = ConfigBuilder::default()
.endpoint("127.0.0.1:8082".to_string())
// Private key is only used for signing authentication messages
.keypair(KeyPair {
public_key,
private_key,
})
// Subscribe to the global consensus topic
.subscribed_topics(vec![TestTopic::Global as u8])
.build()
.unwrap();
// Create a client, specifying the BLS signature algorithm
// and the `QUIC` protocol.
let client = Client::<BLS, Quic>::new(config)
.await
.unwrap();
// Send a direct message to ourselves
client
.send_direct_message(&public_key, b"hello direct".to_vec())
.await
.unwrap();
// Receive the direct message
let message = client
.receive_message()
.await
.unwrap();
// Assert we've received the proper direct message
assert!(
message
== Message::Direct(Direct {
recipient: public_key.serialize().unwrap(),
message: b"hello direct".to_vec()
})
);
// Send a broadcast message to the global topic
client
.send_broadcast_message(vec![TestTopic::Global as u8], b"hello broadcast".to_vec())
.await
.unwrap();
// Receive the broadcast message
let message = client
.receive_message()
.await
.unwrap();
// Assert we've received the proper broadcast message
assert!(
message
== Message::Broadcast(Broadcast {
topics: vec![TestTopic::Global as u8],
message: b"hello broadcast".to_vec()
})
);
}
Full example available here
Running locally can be achieved via the supplied process-compose.yaml
:
process-compose up
It requires installation of KeyDB
or Redis
.
(c) 2024 Espresso Systems.
Push-CDN
was developed by Espresso Systems. While we plan to adopt an open source license, we have not yet selected one. As such, all rights are reserved for the time being. Please reach out to us if you have thoughts on licensing.