1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! Proc macros for Photon pub/sub.
//!
//! ## Entry points
//!
//! - [`topic`] — typed publish/subscribe on a struct; submits a topic descriptor to inventory
//! - [`subscribe`] — registers a handler; requires `Photon::start_executor` at boot
use TokenStream;
/// Marks a struct as a Photon topic, generating typed publish/subscribe APIs.
///
/// # Usage
///
/// ```ignore
/// use photon::topic;
///
/// #[topic(name = "user.notifications", keyed_by = "user_id")]
/// pub struct NotificationPushed {
/// pub user_id: String,
/// }
/// ```
/// Marks a function as a subscription handler registered via inventory.
///
/// # Usage (v1 — `Box<dyn Actor>`)
///
/// ```ignore
/// use photon::{topic, subscribe, Actor, Result};
///
/// #[topic(name = "user.notifications")]
/// pub struct NotificationPushed {
/// pub user_id: String,
/// }
///
/// #[subscribe(topic = "user.notifications", durable = "push-worker")]
/// async fn on_notification(
/// _actor: Box<dyn Actor>,
/// _event: NotificationPushed,
/// ) -> Result<()> {
/// Ok(())
/// }
/// ```
///
/// # Actor bindings (v2)
///
/// The first parameter must be a simple identifier typed as one of:
///
/// - `Box<dyn Actor>` — reconstruct as-is (v1)
/// - `Arc<dyn Actor>` — `Arc::from(reconstruct()?)`
/// - `Box<Concrete>` / `Arc<Concrete>` — downcast via `Actor::into_any`; failure maps to
/// `PhotonError::Identity`
///
/// # Optional injectables (v2)
///
/// After `(actor, payload)` you may add trailing parameters detected by type path:
///
/// - `&Event` — transport event (metadata + raw JSON)
/// - `HandlerCtx` — delivery metadata (`event_id`, `topic_name`, `topic_key`, `seq`)
///
/// Unknown trailing types are rejected at compile time.
///
/// The handler must be `async` and return `photon::Result<()>`. Call
/// `Photon::start_executor` at startup with an identity factory.