Skip to main content

register

Attribute Macro register 

Source
#[register]
Expand description

Registers a subscription static to be started automatically when the application initializes.

Apply this attribute to a static Subscription<T>. It also lets you pass an async fn name directly instead of wrapping it in a boxing closure for Subscription::new.

#[encore::pubsub::register]
static WELCOME: Subscription<String> =
    Subscription::new(&SIGNUPS, "send-welcome", send_welcome).max_concurrency(4);

async fn send_welcome(msg: Message<String>) -> Result<(), encore::Error> {
    Ok(())
}

See encore::pubsub::register.