Comments (4)
These all sound like great ideas! I'd definitely be open to accepting new examples, and if there's anything that you think would be reusable it might make sense to have an actix-web
feature that enables additional functionality within act-zero itself.
My goal with this was to make async/await really easy, but I've only done the bare minimum to get to that point, so there's a ton of opportunities to improve it still.
Testing is something I have thought about a little. My current plan was to implement some kind of "snapshot" functionality that you could use to quickly get the state of all the actors in the system and make assertions about, but it's still very much in the ideas phase... There are also questions like: do we want to be able to make actors completely deterministic? That would certainly help with tests but might be quite difficult to accomplish.
from act-zero.
- dynamic actor launching and cleanup
In several places I have an actor that will dynamically create and destroy actors. I have been doing this with a "Supervisor" actor that creates, and routes messages to, worker actors.
This would be really cool. You could implement a supervision tree and have the supervisor restart actors that die:
async fn spawn_child(&mut self) {
self.child = spawn_actor(...);
let termination = self.child.termination();
self.addr.send_fut_with(|addr| async move {
termination.await;
// The child stopped for some reason, re-spawn it again
send!(addr.spawn_child());
});
}
from: #4 (comment)
I wonder if it would be possible to create an DynamicSupervisor like in elixir: https://hexdocs.pm/elixir/DynamicSupervisor.html
from act-zero.
I've been playing with implementing a trait to allow an actor to handle stream values. My work so far can be found here: https://github.com/dmm/act-zero-stream/blob/main/src/stream.rs
I added the new StreamHandler
trait to the example from your README.
#[async_trait]
impl StreamHandler<String> for SimpleGreeter {
async fn started2(&mut self) {
println!("Stream has started!");
}
async fn handle(&mut self, item: String) {
println!("Got stream item: {}", item);
if let Ok(Produces::Value(greeting)) = self.greet(item).await {
println!("{}", greeting);
}
}
async fn finished(&mut self) {
println!("Stream has stopped!");
}
}
The idea is that an actor will own (in the general sense) a stream and handle stream output as actor messages.
A couple of questions that came up:
- Is there a way to disambiguate a trait method in the
send!
macro? For example here I had to rename myStreamHandler
function tostarted2
so that it wouldn't conflict with theActor::started
function. https://github.com/dmm/act-zero-stream/blob/main/src/stream.rs#L72 - Does this design make sense to you?
from act-zero.
I've added a websocket example: https://github.com/dmm/act-zero-stream/blob/main/websocket/src/websocket_actor.rs
Receiving data from the client works well but now I need to figure out how to share the stream so the actor can send data as well.
from act-zero.
Related Issues (11)
- Working with Tokio Runtime HOT 8
- Road Map for act-zero
- The document of "send!" is inaccurate HOT 3
- Use native async traits?
- Add tracing span to `send` and `call`?
- Kill or stop Actor HOT 3
- Using in a supervision tree style hierarchy HOT 1
- Using in a supervision tree style hierarchy HOT 9
- Waiting for drop to complete
- Upgrade to Tokio 1.0? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from act-zero.