Skip to content
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

Rust 2018 and async/await support #32

Merged
merged 20 commits into from Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "Easily build fast, highly concurrent and resilient applications. An Actor Framework for Rust."
homepage = "https://riker.rs"
repository = "https://github.com/riker-rs/riker"
Expand All @@ -27,12 +28,13 @@ members = [
bytes = "0.4"
chrono = "0.4"
config = "0.9"
futures-preview = "0.2.2"
futures-preview = "0.3.0-alpha.10"
log = { version = "0.4", features = ["std"] }
rand = "0.4"
regex = "0.2"
uuid = { version = "0.6", features = ["v4"] }
pin-utils = "0.1.0-alpha.3"

[dev-dependencies]
riker-default = { path = "riker-default", version = "0.1.8" }
riker-default = { path = "riker-default", version = "0.1.9" }
riker-testkit = "0.1.0"
1 change: 1 addition & 0 deletions riker-default/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker-default"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "Riker's default Model and modules providing core services"
homepage = "https://riker.rs"
repository = "https://github.com/riker-rs/riker-default"
Expand Down
1 change: 1 addition & 0 deletions riker-default/riker-deadletter/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker-deadletter"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "A Dead Letters logger for Riker"
homepage = "https://riker.rs"
repository = "https://github.com/riker-rs/riker-default"
Expand Down
5 changes: 1 addition & 4 deletions riker-default/riker-deadletter/src/lib.rs
@@ -1,10 +1,7 @@
#[macro_use]
extern crate log;
extern crate riker;

use riker::actors::*;
use riker::actor::All;
use riker::system::DeadLetterProps;
use log::{log, info};

pub struct DeadLettersActor<Msg: Message> {
dl: ActorRef<Msg>,
Expand Down
6 changes: 4 additions & 2 deletions riker-default/riker-dispatcher/Cargo.toml
Expand Up @@ -2,14 +2,16 @@
name = "riker-dispatcher"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "A Dispatcher module for Riker powered by `Futures::execution::ThreadPool`"
homepage = "https://riker.rs"
repository = "https://github.com/riker-rs/riker-default"
license = "MIT"
readme = "README.md"

[dependencies]
riker = { path = "../../", version = "0.1.9" }
riker = { path = "../../", version = "0.1.8" }
config = "0.9"
futures-preview = "0.2.2"
# futures-preview = "0.2.2"
futures-preview = "0.3.0-alpha.10"
futures-cpupool = "0.1.8"
12 changes: 5 additions & 7 deletions riker-default/riker-dispatcher/src/lib.rs
@@ -1,13 +1,11 @@
extern crate config;
extern crate futures;
extern crate riker;
#![feature(futures_api)]

use futures::{Future, Never};
use futures::Future;
use futures::executor::{ThreadPool, ThreadPoolBuilder};
use futures::task::{SpawnExt};
use config::Config;

use riker::kernel::Dispatcher;
use riker::futures_util::spawn;

pub struct ThreadPoolDispatcher {
inner: ThreadPool,
Expand All @@ -26,9 +24,9 @@ impl Dispatcher for ThreadPoolDispatcher {
}

fn execute<F>(&mut self, f: F)
where F: Future<Item=(), Error=Never> + Send + 'static
where F: Future<Output = ()> + Send + 'static
{
self.inner.run(spawn(f)).unwrap();
let _ = self.inner.spawn(f);
}
}

Expand Down
1 change: 1 addition & 0 deletions riker-default/riker-log/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker-log"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "A Log module for Riker."
homepage = "https://riker.rs/logging"
repository = "https://github.com/riker-rs/riker-default"
Expand Down
37 changes: 16 additions & 21 deletions riker-default/riker-log/src/lib.rs
@@ -1,12 +1,7 @@
extern crate config;
extern crate chrono;
extern crate riker;
#[macro_use]
extern crate runtime_fmt;

use std::marker::PhantomData;

use config::Config;
use runtime_fmt::{rt_println, rt_format_args};

use riker::actors::*;
use riker::system::LoggerProps;
Expand All @@ -27,18 +22,18 @@ impl<Msg> Actor for SimpleLogger<Msg>
fn system_receive(&mut self, _: &Context<Self::Msg>, msg: SystemMsg<Self::Msg>, _: Option<ActorRef<Self::Msg>>) {
if let SystemMsg::Log(entry) = msg {
let now = chrono::Utc::now();
let f_match: Vec<&String> = self.cfg.filter.iter()
.filter(|f| entry.module.as_ref().map(|m| m.contains(*f)).unwrap_or(false))
.collect();
if f_match.is_empty() {
rt_println!(self.cfg.log_fmt,
date = now.format(&self.cfg.date_fmt),
time = now.format(&self.cfg.time_fmt),
level = entry.level,
module = entry.module.unwrap_or_default(),
body = entry.body
).unwrap();
}
let f_match: Vec<&String> = self.cfg.filter.iter()
.filter(|f| entry.module.as_ref().map(|m| m.contains(*f)).unwrap_or(false))
.collect();
if f_match.is_empty() {
rt_println!(self.cfg.log_fmt,
date = now.format(&self.cfg.date_fmt),
time = now.format(&self.cfg.time_fmt),
level = entry.level,
module = entry.module.unwrap_or_default(),
body = entry.body
).unwrap();
}
}
}
}
Expand Down Expand Up @@ -70,16 +65,16 @@ struct LoggerConfig {
time_fmt: String,
date_fmt: String,
log_fmt: String,
filter: Vec<String>,
filter: Vec<String>,
}

impl<'a> From<&'a Config> for LoggerConfig {
fn from(config: &Config) -> Self {
LoggerConfig {
time_fmt: config.get_str("log.time_format").unwrap().to_string(),
date_fmt: config.get_str("log.date_format").unwrap().to_string(),
log_fmt: config.get_str("log.log_format").unwrap().to_string(),
filter: config.get_array("log.filter").unwrap_or(vec![]).into_iter().map(|e| e.to_string()).collect(),
log_fmt: config.get_str("log.log_format").unwrap().to_string(),
filter: config.get_array("log.filter").unwrap_or(vec![]).into_iter().map(|e| e.to_string()).collect(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion riker-default/riker-mapvec/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker-mapvec"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "Simple in-memory datastore for Riker persistent actors"
homepage = "https://riker.rs"
repository = "https://github.com/riker-rs/riker-default"
Expand All @@ -14,5 +15,5 @@ riker = { path = "../../", version = "0.1.9" }
config = "0.9"

[dev-dependencies]
riker-default = { path = "../", version = "0.1.8" }
riker-default = { path = "../", version = "0.1.9" }
riker-testkit = "0.1.0"
3 changes: 0 additions & 3 deletions riker-default/riker-mapvec/src/lib.rs
@@ -1,6 +1,3 @@
extern crate config;
extern crate riker;

use std::sync::{Arc, Mutex};
use std::collections::HashMap;

Expand Down
1 change: 1 addition & 0 deletions riker-default/riker-timer/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
name = "riker-timer"
version = "0.1.9"
authors = ["Lee Smith <leenozara@gmail.com>"]
edition = "2018"
description = "A message scheduler for Riker"
homepage = "https://riker.rs/scheduling"
repository = "https://github.com/riker-rs/riker-default"
Expand Down
4 changes: 0 additions & 4 deletions riker-default/riker-timer/src/lib.rs
@@ -1,7 +1,3 @@
extern crate config;
extern crate riker;
extern crate uuid;

use std::time::{Duration, SystemTime};
use std::thread;
use std::sync::mpsc::{channel, Sender};
Expand Down
7 changes: 0 additions & 7 deletions riker-default/src/lib.rs
@@ -1,10 +1,3 @@
extern crate riker;
extern crate riker_dispatcher;
extern crate riker_log;
extern crate riker_deadletter;
extern crate riker_mapvec;
extern crate riker_timer;

use std::marker::PhantomData;

use riker::model::Model;
Expand Down
8 changes: 4 additions & 4 deletions src/actor/actor.rs
@@ -1,8 +1,8 @@
#![allow(unused_variables)]

use protocol::{Message, SystemMsg, ActorMsg};
use actor::actor_ref::ActorRef;
use actor::actor_cell::{Context, PersistenceConf};
use crate::protocol::{Message, SystemMsg, ActorMsg};
use crate::actor::actor_ref::ActorRef;
use crate::actor::actor_cell::{Context, PersistenceConf};

/// An Actor represents a struct that will be scheduled for execution when it is sent a message.
///
Expand Down Expand Up @@ -257,7 +257,7 @@ impl<A: Actor + ?Sized> Actor for Box<A> {
}

/// The actor trait object
pub type BoxActor<Msg> = Box<Actor<Msg=Msg> + Send>;
pub type BoxActor<Msg> = Box<dyn Actor<Msg=Msg> + Send>;

/// Supervision strategy
///
Expand Down