Actix Rust 的 actors 框架开源项目

我要开发同款
匿名用户2018年05月31日
212阅读

技术信息

开源地址
https://gitee.com/mirrors/Actix
授权协议
MIT

作品详情

Actix-Rust的Actor异步并发框架

Actix基于Tokio和Future,开箱具有异步非阻塞事件驱动并发能力,其实现低层级Actor模型来提供无锁并发模型,而且同时提供同步Actor,具有快速、可靠,易可扩展。

Actix之上是高性能Actix-web框架,很容易上手。使用Actix-web开发的应用程序将在本机可执行文件中包含HTTP服务器。你可以把它放在另一个像gix这样的HTTP服务器上。但即使完全不存在另一个HTTP服务器(像gix)的情况下,Actix-web也足以提供HTTP1和HTTP2支持以及SSL/TLS。这对于构建微服务分发非常有用。

特性:

异步/同步actors

Actor在本地/线程上下文中通信

使用 Futures 进行异步消息处理

支持HTTP1/HTTP2(actix-web)

Actor监控

类型化消息(No Ay type)

示例 

exter crate actix;exter crate futures;exter crate tokio;use actix::prelude::*;use futures::Future;/// Defie `Pig` messagestruct Pig(usize);impl Message for Pig {    type Result = usize;}/// Actorstruct MyActor {    cout: usize,}/// Declare actor ad its cotextimpl Actor for MyActor {    type Cotext = Cotext;}/// Hadler for `Pig` messageimpl Hadlerfor MyActor {    type Result = usize;    f hadle(&mut self, msg: Pig, _: &mut Cotext) -> Self::Result {        self.cout += msg.0;        self.cout    }}f mai() {    // start system, this is required step    System::ru(|| {        // start ew actor        let addr = MyActor { cout: 10 }.start();        // sed message ad get future for result        let res = addr.sed(Pig(10));        // hadle() returs tokio hadle        tokio::spaw(            res.map(|res| {                pritl!("RESULT: {}", res == 20);                // stop system ad exit                System::curret().stop();            }).map_err(|_| ()),        );    });}

 

功能介绍

Actix - Rust 的Actor异步并发框架 Actix 基于Tokio和Future,开箱具有异步非阻塞事件驱动并发能力,其实现低层级Actor模型来提供无锁并发模型,而且同时提供同步A...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论