pub struct HandlerCtx<'a> {
pub event_id: &'a str,
pub topic_name: &'a str,
pub topic_key: Option<&'a str>,
pub seq: i64,
}Expand description
Delivery metadata for a single handler invocation.
Inject as a trailing parameter on a #[photon::subscribe] handler (after actor and
payload), alone or alongside &Event:
ⓘ
#[photon::subscribe(topic = "orders", durable = "worker")]
async fn on_order(
_actor: Box<dyn Actor>,
order: OrderPlaced,
ctx: HandlerCtx<'_>,
) -> photon::Result<()> {
tracing::info!(event_id = %ctx.event_id, seq = ctx.seq, "handling");
Ok(())
}Values borrow from the transport crate::models::Event passed to the generated
invoker for the duration of the handler future.
Fields§
§event_id: &'a strUnique event ID (UUID string from the transport event).
topic_name: &'a strTopic name the event was published on.
topic_key: Option<&'a str>Partition / routing key when the topic is keyed.
seq: i64Monotonic sequence number for this topic (and key, when keyed).
Implementations§
Source§impl<'a> HandlerCtx<'a>
impl<'a> HandlerCtx<'a>
Sourcepub fn from_event(event: &'a Event) -> Self
pub fn from_event(event: &'a Event) -> Self
Build from a transport crate::models::Event.
Trait Implementations§
Source§impl<'a> Clone for HandlerCtx<'a>
impl<'a> Clone for HandlerCtx<'a>
Source§fn clone(&self) -> HandlerCtx<'a>
fn clone(&self) -> HandlerCtx<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for HandlerCtx<'a>
Auto Trait Implementations§
impl<'a> Freeze for HandlerCtx<'a>
impl<'a> RefUnwindSafe for HandlerCtx<'a>
impl<'a> Send for HandlerCtx<'a>
impl<'a> Sync for HandlerCtx<'a>
impl<'a> Unpin for HandlerCtx<'a>
impl<'a> UnsafeUnpin for HandlerCtx<'a>
impl<'a> UnwindSafe for HandlerCtx<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more