Skip to main content

spawn

Function spawn 

Source
pub fn spawn(relay: KafkaRelay, fan_out: SocketFanOut) -> JoinHandle<()> ⓘ
Expand description

Run the relay in the background, reconnecting when it falls over.

Call it from a provider’s boot, in the process that serves WebSockets:

ⓘ
let relay = KafkaRelay::new(Arc::clone(&kafka), "broadcasts");
relay::spawn(relay, SocketFanOut::new(Arc::clone(&rooms)));

The task carries the facade scope with it, so anything the fan-out reaches can resolve from the container — a spawned task inherits neither the thread nor the task scope on its own.