-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finalize actor documentation #1908
Finalize actor documentation #1908
Conversation
9822fac
to
33813e9
Compare
Robot Results
Passed Tests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} | ||
|
||
pub struct Concurrent; | ||
pub struct Sequential; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_concurrency = 1
means sequential? Then, why do we need to have this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is something to improve here.
@@ -1,3 +1,59 @@ | |||
//! Actors that convert each input message into a sequence of output messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know the converter, now I know it! Looks so nice!!!
382d2c1
to
cb327b8
Compare
39e99f2
to
02d2ac6
Compare
/// The builder of a MessageBox must implement this trait for every message type that can be sent to it | ||
/// The [Builder] of an [Actor](crate::Actor) must implement this trait for every message type that can be sent to it | ||
/// | ||
/// A sink might be interested only by a subset of the messages emitted by the source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A sink might be interested only by a subset of the messages emitted by the source. | |
/// A sink might be interested only in a subset of the messages emitted by the source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/// The builder of an [Actor](crate::Actor) must implement this trait | ||
/// for every message type that it can receive from its peers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The builder of an [Actor](crate::Actor) must implement this trait | |
/// for every message type that it can receive from its peers | |
/// The builder of an [Actor](crate::Actor) must implement this trait | |
/// for every message type that it can emit to its peers. | |
/// To receive messages from a `MessageSource<M, C>`, the peer must be a `MessageSink<M, C>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -153,13 +198,15 @@ pub trait MessageSource<M: Message, Config> { | |||
} | |||
} | |||
|
|||
/// The builder of a MessageBox must implement this trait to receive requests from the runtime | |||
/// The builder of an [Actor](crate::Actor) must implement this trait | |||
/// to receive [runtime requests](crate::RuntimeRequest] from the [Runtime](crate::Runtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// to receive [runtime requests](crate::RuntimeRequest] from the [Runtime](crate::Runtime) | |
/// to receive [runtime requests](crate::RuntimeRequest]s like shutdown requests from the [Runtime](crate::Runtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
/// A trait to connect an actor under-construction to peer actors | ||
/// that use the service provided by this actor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// A trait to connect an actor under-construction to peer actors | |
/// that use the service provided by this actor. | |
/// A trait that defines that an actor provides a service by accepting `Request` messages and sending `Response` from/to its peers. | |
/// In order to connect to a to `ServiceProvider<Req, Res, Conf>` and avail its services, the peer must be a `ServiceConsumer<Req, Res, Conf>`. | |
/// The config parameter is typically used by the `ServiceConsumer` to register any message filtering criteria to the `ServiceProvider`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied the suggestion
} | ||
} | ||
|
||
/// Build a message box ready to be used by the service actor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Build a message box ready to be used by the service actor | |
/// Build a message box ready to be used by the server actor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/// Start to build a new message box for a service | ||
pub fn new(service_name: &str, capacity: usize) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Start to build a new message box for a service | |
pub fn new(service_name: &str, capacity: usize) -> Self { | |
/// Start to build a new message box for the server actor | |
pub fn new(server_name: &str, capacity: usize) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
|
||
/// Build a message box ready to be used by the service actor | ||
fn build_service(self) -> ServerMessageBox<Request, Response> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn build_service(self) -> ServerMessageBox<Request, Response> { | |
fn build(self) -> ServerMessageBox<Request, Response> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed build_server
to avoid confusion with the Builder::build()
method also implemented by this struct.
/// An actor which builder is a `MessageSink<M, C>` can be connected to any other actor | ||
/// which builder is a `MessageSource<M, C>` so that the sink can receive messages from that source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// An actor which builder is a `MessageSink<M, C>` can be connected to any other actor | |
/// which builder is a `MessageSource<M, C>` so that the sink can receive messages from that source. | |
/// An actor whose builder is a `MessageSink<M, C>` can be connected to any other actor | |
/// whose builder is a `MessageSource<M, C>` so that the sink can receive messages from that source. |
ChatGPT confirmed that it is grammatically okay to use "whose" in this context ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
crates/core/tedge_actors/src/lib.rs
Outdated
//! | ||
//! ``` | ||
//! # use crate::tedge_actors::{Actor, RuntimeError, MessageReceiver, RuntimeRequest, Sender, SimpleMessageBox}; | ||
//! # use async_trait::async_trait; | ||
//! # | ||
//! /// State of the calculator actor | ||
//! /// State of the calculator actor along its message box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! /// State of the calculator actor along its message box | |
//! /// State of the calculator actor along with its message box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
crates/core/tedge_actors/src/lib.rs
Outdated
//! /// from where input messages are received | ||
//! /// and to which output messages are sent. | ||
//! /// | ||
//! /// More sophisticated actors might used specific boxes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! /// More sophisticated actors might used specific boxes, | |
//! /// More sophisticated actors might use specific boxes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
crates/core/tedge_actors/src/lib.rs
Outdated
//! - Two actor builders, a `consumer: ServiceConsumer<I,O,C>` and a `producer: ServiceProvider<I,O,C>` | ||
//! can then be connected to each other : `consumer.set_connection(producer)` | ||
//! The connection builder traits work by pairs: | ||
//! - A [MessageSink](crate::MessageSink) connects a [MessageSource](crate::MessageSource), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! - A [MessageSink](crate::MessageSink) connects a [MessageSource](crate::MessageSource), | |
//! - A [MessageSink](crate::MessageSink) connects to a [MessageSource](crate::MessageSource), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
//! The connection builder traits work by pairs: | ||
//! - A [MessageSink](crate::MessageSink) connects a [MessageSource](crate::MessageSource), | ||
//! so the messages sent by the latter will be received by the former. | ||
//! - A [ServiceConsumer](crate::ServiceConsumer) connects a [ServiceProvider](crate::ServiceProvider), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! - A [ServiceConsumer](crate::ServiceConsumer) connects a [ServiceProvider](crate::ServiceProvider), | |
//! - A [ServiceConsumer](crate::ServiceConsumer) connects to a [ServiceProvider](crate::ServiceProvider), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
crates/core/tedge_actors/src/lib.rs
Outdated
//! impl ServiceProvider<SomeInput,SomeOutput,SomeConfig> for SomeActorBuilder { | ||
//! /// Exchange two message senders with the new peer, so each can send messages to the other | ||
//! /// | ||
//! /// The service registers the new consumer and ist sender (i.e. where to send response), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! /// The service registers the new consumer and ist sender (i.e. where to send response), | |
//! /// The service registers the new consumer and its sender (i.e. where to send response), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
crates/core/tedge_actors/src/lib.rs
Outdated
//! - Any actor can send [RuntimeAction] to the runtime, | ||
//! to spawn a new actor or to request a global shutdown of the application. | ||
//! - An actor can subscribe to the [RuntimeEvent] published by the runtime, | ||
//! to be notified of actor events as start, termination or crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! to be notified of actor events as start, termination or crash. | |
//! to be notified of actor events such as start, termination or crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
crates/core/tedge_actors/src/lib.rs
Outdated
//! | ||
//! To run an actor `A` using the [tedge_actors::Runtime](crate::Runtime) requires more than just | ||
//! an [Actor] implementation. One needs an [actor builder](crate::builders) that implements: | ||
//! - `Builder<A>` to let the runtime creates the actor instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! - `Builder<A>` to let the runtime creates the actor instance, | |
//! - `Builder<A>` to let the runtime create the actor instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
The Calculator can no more implement the Actor and Server traits as the former expects the message box to be owned by the actor while the latter wraps the server with an external message box. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
3652e5c
to
4c73c2b
Compare
Proposed changes
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments