Skip to content

Commit

Permalink
riker-rs#117 Return ScheduleId instead of UUID from scheduling functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoe7 committed Jun 29, 2020
1 parent 76547c1 commit 8a5242e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/target
**/*.rs.bk
.vscode
.idea
Cargo.lock
**/Cargo.lock

Expand Down
8 changes: 4 additions & 4 deletions src/actor/actor_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
mailbox::{AnySender, MailboxSender},
},
system::{
timer::{Job, OnceJob, RepeatJob, Timer},
timer::{Job, OnceJob, RepeatJob, Timer, ScheduleId},
ActorSystem, Run, SystemCmd, SystemMsg,
},
validate::InvalidPath,
Expand Down Expand Up @@ -616,7 +616,7 @@ where
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand All @@ -643,7 +643,7 @@ where
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand All @@ -669,7 +669,7 @@ where
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ impl Debug for AnyMessage {

pub mod actors {
pub use crate::actor::*;
pub use crate::system::{ActorSystem, Run, SystemBuilder, SystemEvent, SystemMsg, Timer};
pub use crate::system::{ActorSystem, Run, SystemBuilder, SystemEvent, SystemMsg, Timer, ScheduleId};
pub use crate::{AnyMessage, Message};
}
8 changes: 4 additions & 4 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{error::Error, fmt};
use crate::actor::BasicActorRef;

// Public riker::system API (plus the pub data types in this file)
pub use self::timer::{BasicTimer, Timer};
pub use self::timer::{BasicTimer, Timer, ScheduleId};

#[derive(Clone, Debug)]
pub enum SystemMsg {
Expand Down Expand Up @@ -713,7 +713,7 @@ impl Timer for ActorSystem {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand All @@ -740,7 +740,7 @@ impl Timer for ActorSystem {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand All @@ -766,7 +766,7 @@ impl Timer for ActorSystem {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message,
Expand Down
8 changes: 5 additions & 3 deletions src/system/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use crate::{

pub type TimerRef = mpsc::Sender<Job>;

pub type ScheduleId = Uuid;

pub trait Timer {
fn schedule<T, M>(
&self,
Expand All @@ -23,7 +25,7 @@ pub trait Timer {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message;
Expand All @@ -34,7 +36,7 @@ pub trait Timer {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message;
Expand All @@ -45,7 +47,7 @@ pub trait Timer {
receiver: ActorRef<M>,
sender: Sender,
msg: T,
) -> Uuid
) -> ScheduleId
where
T: Message + Into<M>,
M: Message;
Expand Down
3 changes: 1 addition & 2 deletions tests/scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use riker_testkit::probe::{Probe, ProbeReceive};

use chrono::{Duration as CDuration, Utc};
use std::time::Duration;
use uuid::Uuid;

#[derive(Clone, Debug)]
pub struct TestProbe(ChannelProbe<(), ()>);
Expand Down Expand Up @@ -81,7 +80,7 @@ fn schedule_at_time() {
struct ScheduleRepeat {
probe: Option<TestProbe>,
counter: u32,
schedule_id: Option<Uuid>,
schedule_id: Option<ScheduleId>,
}

impl Actor for ScheduleRepeat {
Expand Down

0 comments on commit 8a5242e

Please sign in to comment.