Skip to content

sterrlia/ascolt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ascolt

crates.io version docs.rs docs CI build Dependency Status Minimum Supported Rust Version

Async runtime-agnostic actor framework

Features

  • Clean type-safe syntax
  • Async support
  • Both unbounded and bounded channels supported
  • Handler errors can trigger actor stop, forced stop, or restart (behavior is customizable)
  • No heavy macros
  • No unsafe code

Examples

let first_actor = FirstActor {};
let (first_actor_tx, first_actor_rx) = ascolt::bounded_channel(100);
let second_actor = SecondActor { first_actor_tx };
let (second_actor_tx, second_actor_rx) = ascolt::bounded_channel(100);

// if using tokio runtime
tokio::spawn(ascolt::run(actor, first_actor_rx));
tokio::spawn(ascolt::run(second_actor, second_actor_rx));

first_actor_tx.tell(SomeRequest { number: 3 })
    .await?; // fire-and-forget

let result = second_actor_tx
    .ask(SecondActorCalcRequest(10))
    .await?; // request-response

println!("Result: {}", result.0);

More examples located at examples directory.

What can be added

  • Panic isolation
  • Backpressure management
  • Supervisor for controlling multiple actors
  • Dependency graph (e.g., automatically shut down actors when the actors they depend on stop)
  • Actor communication over the network

Alternatives

About

Async runtime-agnostic actor framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages