Skip to content

klaatu01/neutron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neutron - This package is currently a Work In Progress and is NOT Production Ready

An Apache Pulsar client library, built with pure rust 🦀 and requires no C++ dependencies.

Features:

  • Pure Rust, No C++ Dependencies 🦀
  • Consumer Client 📥
  • Producer Client 📤
  • Plugin Support 🔌
  • Multi/Dual Consumer & Producer Support 🤝
  • TLS Support via rustls 🔐
  • Async Resolution of Send & Acks 🪓
  • Batching Support 📦
  • Automatic Reconnection ♻️
  • Automatic Operation Retry 🚀

Installation

Using Cargo Add

This will install the newest version of neutron into your cargo.toml

cargo add neutron

Manually

As this is currently in prerelease you must use the git ssh address directly.

neutron = "0.0.2"

Features

The json feature provides automatic de/serialization through serde_json.

neutron = { version = "0.0.2", features = ["json"] }

Example

This is a simple example of a consumer that listens to a topic and prints the message. with the json feature enabled

use neutron::{ConsumerBuilder, Message};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
#[allow(dead_code)]
struct Data {
    name: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    env_logger::init();
    let pulsar_config = neutron::PulsarConfig {
        endpoint_url: "pulsar://localhost".to_string(),
        endpoint_port: 6650,
    };

    let pulsar = neutron::PulsarBuilder::new()
        .with_config(pulsar_config)
        .build()
        .run();

    let consumer = ConsumerBuilder::new()
        .with_topic("test")
        .with_subscription("test")
        .with_consumer_name("test")
        .connect(&pulsar)
        .await?;


    loop {
        let response: Message<Data> = consumer.next_message().await?;
        log::info!("Received message: {:?}", response.payload);
        consumer.ack(&response.ack).await?;
    }
}

About

A simple and stable Pulsar Client Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages