Skip to content

Instantly share code, notes, and snippets.

@gterzian
Created May 11, 2020 05:06
Show Gist options
  • Save gterzian/1f5e663ac3fe216dda94fbad71b5f03a to your computer and use it in GitHub Desktop.
Save gterzian/1f5e663ac3fe216dda94fbad71b5f03a to your computer and use it in GitHub Desktop.
// Spawn the "payment" service.
let _ = thread::spawn(move || loop {
match payment_request_receiver.recv() {
Ok(PaymentRequest::NewOrder(order_id)) => {
// Process the payment for a new order.
let _ = payment_result_sender.send(PaymentResult(order_id, true));
}
Ok(PaymentRequest::ShutDown) => {
break;
}
Err(_) => panic!("Error receiving a payment request."),
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment