Channels
A subscription is a channel the service receives on, and a topic a channel it sends to; neither carries a googlepubsub binding.
A channel the service receives on is named after the subscription.
The topic behind a subscription is a fact of the service's infrastructure, which the document, built before anything connects, does not see.
A channel the service publishes to reports the topic the mount site resolved as its address: a reply type's #[outgoing(name)], a reply("dest") clause, or a slot's destination.
The channel binding of googlepubsub describes a topic's configuration: labels, retention, storage policy and schema.
No descriptor or publish policy holds those, so channels carry no binding.
Example
The subscription orders-workers is a channel the service receives on, and the topic receipts one it sends to.
- Macros
- Manual
/// The subscription `orders-workers` is a channel the service receives on, and the topic
/// `receipts` a channel it sends to.
#[subscriber(GooglePubSub::new("orders-workers"), reply)]
async fn receipt(order: &Order) -> Receipt {
Receipt { order_id: order.id }
}
/// The subscription `orders-workers` is a channel the service receives on, and the topic
/// `receipts` a channel it sends to.
struct ReceiptFor;
impl Handle<Order, Receipt> for ReceiptFor {
fn handle(
&self,
order: &Order,
_outs: &(),
_ctx: &mut Context<'_>,
) -> impl Future<Output = Result<Receipt, HandlerOutcome>> {
ready(Ok(Receipt { order_id: order.id }))
}
}
fn orders() -> GooglePubSub {
GooglePubSub::new("orders-workers")
}