startup

Attribute Macro startup 

Source
#[startup]
Expand description

Marker attribute for service startup hook. Use on a single method within a #[service] impl block. The method runs after service creation, before workers start receiving messages.

Note: Cannot call other services - workers aren’t running yet.

#[service]
impl CacheService {
    #[startup]
    async fn load_cache(&self) {
        // Runs before any messages are processed
        let data = self.db.load_all().await;
        *self.cache.write() = data;
    }
}