nan-serve-publish-event

Crates.ionan-serve-publish-event
lib.rsnan-serve-publish-event
version0.1.0
created_at2025-01-05 01:44:11.857345+00
updated_at2025-01-05 01:44:11.857345+00
descriptionTokio event publisher for nanoservices
homepage
repository
max_upload_size
id1504385
size2,892
Maxwell Flitton (maxwellflitton)

documentation

README

Nanoservices event publisher

A basic proc macro crate for publishing events. We can subscribe to events with the following code:

#[derive(Serialize, Deserialize, Debug)]
struct Two;

#[subscribe_to_event]
async fn test2(two: Two) {
    println!("calling from test2 function with: {:?}", two);
}

This generates the code for a standard function under the name as it is defined as, and a slightly mangled function which is registered with the event subscriber. If an event is then published with the Two then all functions subscribed to the Two event will be called with the instance of the Two struct. We can then publish the event with the following code:

let two = Two {};
publish_event!(two);

The test2 function will then be called with the Two struct instance. This is a basic event publisher and subscriber system for nanoservices.

Commit count: 0

cargo fmt