Skip to content

Commit

Permalink
documentation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonHartley committed Feb 5, 2023
1 parent 660fea5 commit b8cfc35
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
11 changes: 10 additions & 1 deletion coerce/src/actor/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
//!
//! ### Example
//! ```rust,no_run
//! use coerce::actor::message::Handler;
//! use coerce::actor::Actor;
//! use coerce::actor::message::{Message, Handler};
//! use coerce::actor::context::ActorContext;
//!
//! struct MyActor;
//!
//! impl Actor for MyActor { }
//!
//! struct MyMessage;
//!
//! impl Message for MyMessage { type Result = (); }
//!
//! #[async_trait]
//! impl Handler<MyMessage> for MyActor {
//! async fn handle(&mut self, message: MyMessage, ctx: &mut ActorContext) {
Expand Down
6 changes: 5 additions & 1 deletion coerce/src/actor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
//! use async_trait::async_trait;
//! use tokio::sync::oneshot::{channel, Sender};
//!
//! struct ParentActor { child_count: usize, completed_actors: usize, on_work_completed: Option<Sender<usize>>, }
//! struct ParentActor {
//! child_count: usize,
//! completed_actors: usize,
//! on_work_completed: Option<Sender<usize>>,
//! }
//!
//! struct ChildActor;
//!
Expand Down
30 changes: 27 additions & 3 deletions coerce/src/remote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
//!
//! Coerce clusters are identified by a [`NodeId`] and a string-based node tag.
//!
//! The easiest way to create a full, batteries-included clustered actor system, is by using the [`RemoteActorSystemBuilder`].
//! From here, you can configure and create a [`RemoteActorSystem`].
//! The easiest way to create a full, batteries-included clustered actor system, is by
//! using the [`RemoteActorSystemBuilder`]. From here, you can customise and
//! create a [`RemoteActorSystem`].
//!
//! ## Remote-enabled messages
//! Messages are not available to be handled remotely by default, and do require being registered
Expand Down Expand Up @@ -33,7 +34,12 @@
//! of a message of type `MyMessageType` registered, with the actor that processes the
//! message as type `MyActorType`.
//!
//! ```rust,no_run
//! Note that a prerequisite for messages to be able to be transmitted remotely is that as part
//! of defining the message, it must define how to serialise and deserialise to and from a `Vec<u8>`.
//!
//! ```rust
//! use coerce::actor::Actor;
//! use coerce::actor::message::{Message, MessageUnwrapErr, MessageWrapErr};
//! use coerce::remote::system::RemoteActorSystem;
//!
//! let remote_system = RemoteActorSystem::builder()
Expand All @@ -44,6 +50,24 @@
//! handlers
//! .with_handler::<MyActorType, MyMessageType>("MyActorType.MyMessageType")
//! });
//!
//! struct MyActor;
//!
//! impl Actor for MyActor { }
//!
//! struct MyMessage;
//!
//! impl Message for MyMessage {
//! type Result = ();
//!
//! fn as_bytes(&self) -> Result<Vec<u8>, MessageWrapErr> {
//! Ok(vec![])
//! }
//!
//! fn from_bytes(_: Vec<u8>) -> Result<Self, MessageUnwrapErr> {
//! Ok(Self)
//! }
//! }
//! ```
//!
//! [`NodeId`]: system::NodeId
Expand Down

0 comments on commit b8cfc35

Please sign in to comment.