Skip to content

Commit

Permalink
fix derive Actor example
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed Jan 15, 2025
1 parent 16a7300 commit 9618dc7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions actor-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ proc-macro = true
[dependencies]
syn = "2.0"
quote = "1.0"

[dev-dependencies]
ceramic-actor.workspace = true
async-trait.workspace = true
tokio.workspace = true
22 changes: 22 additions & 0 deletions actor-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,31 @@ use syn::{parse_macro_input, Attribute, DeriveInput, GenericParam, Lit};
///
/// # Example
/// ```
/// # use ceramic_actor::{Handler, Message};
/// use ceramic_actor::{Actor, actor_envelope};
///
/// #[derive(Actor)]
/// #[actor(envelope = "PlayerEnv", handle = "PlayerH", actor_trait = "PlayerI")]
/// pub struct Player { }
///
/// actor_envelope!{
/// PlayerEnv,
/// PlayerI,
/// Score => ScoreMessage,
/// }
///
/// # #[async_trait::async_trait]
/// # impl Handler<ScoreMessage> for Player {
/// # async fn handle(&mut self, message: ScoreMessage) -> <ScoreMessage as Message>::Result {
/// # todo!()
/// # }
/// # }
///
/// # #[derive(Debug)]
/// # struct ScoreMessage { }
/// # impl Message for ScoreMessage {
/// # type Result = ();
/// # }
/// ```
#[proc_macro_derive(Actor, attributes(actor))]
pub fn actor(item: TokenStream) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion actor/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ macro_rules! actor_envelope {
actor.handle(m),
traced.span,
).await).is_err() {
::tracing::warn!("failed to send message to actor");
$crate::tracing::warn!("failed to send message to actor");
}
}
)*
Expand Down

0 comments on commit 9618dc7

Please sign in to comment.