Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from gandro/build-on-stable
Browse files Browse the repository at this point in the history
Build on Rust 1.21 stable
  • Loading branch information
gandro authored Dec 5, 2017
2 parents 900f1ee + 32adf4c commit ea2d1d7
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: rust
rust:
- stable
- nightly
script:
- cargo test --verbose --all
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Please follow the [documentation](http://strymon-system.github.io/docs/) and gui
## Requirements

- Unix-like environment (we use Linux, Mac OS X)
- Rust nightly (2017-08-31 or newer)
- [Rust 1.21](https://www.rust-lang.org/) or newer
- git

## Contribute
Expand Down
1 change: 1 addition & 0 deletions apps/topology-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ abomonation = "0.4.6"
abomonation_derive = "0.2.2"
serde = "1.0"
serde_derive = "1.0"
typename = "0.1"

[dependencies.strymon_runtime]
path = "../../src/strymon_runtime"
4 changes: 3 additions & 1 deletion apps/topology-generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern crate abomonation_derive;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate typename;

use rand::{Rng, SeedableRng, StdRng};

Expand All @@ -25,7 +27,7 @@ pub type LinkWeight = u64;
/// A unidirectional connection between two switches
pub type Connection = (NodeId, NodeId, LinkWeight);

#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub enum Entity {
Connection(Connection),
Switch(NodeId),
Expand Down
1 change: 1 addition & 0 deletions src/strymon_model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ abomonation = "0.4.6"
abomonation_derive = "0.2.2"
serde = "1.0"
serde_derive = "1.0"
typename = "0.1"
41 changes: 20 additions & 21 deletions src/strymon_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(core_intrinsics)]
#[macro_use]
extern crate typename;

extern crate serde;
#[macro_use]
Expand All @@ -17,9 +18,10 @@ extern crate abomonation;
extern crate abomonation_derive;

use std::fmt;
use std::intrinsics::type_name;

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
use typename::TypeName;

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct TopicId(pub u64);

impl From<u64> for TopicId {
Expand All @@ -28,23 +30,20 @@ impl From<u64> for TopicId {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct TopicType {
pub name: String,
}

impl TopicType {
pub fn of<T>() -> Self {
// TODO(swicki): This currently required unstable Rust, we really
// should either use NamedType instead or figure out if we can derive
// a schema from serde instead
pub fn of<T: TypeName>() -> Self {
TopicType {
name: unsafe { type_name::<T>() }.to_string(),
name: T::type_name(),
}
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub enum TopicSchema {
Collection(TopicType),
Stream(TopicType, TopicType),
Expand Down Expand Up @@ -77,15 +76,15 @@ impl fmt::Display for TopicSchema {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Topic {
pub id: TopicId,
pub name: String,
pub addr: (String, u16),
pub schema: TopicSchema,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct QueryId(pub u64);

impl From<u64> for QueryId {
Expand All @@ -94,7 +93,7 @@ impl From<u64> for QueryId {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Query {
pub id: QueryId,
pub name: Option<String>,
Expand All @@ -104,21 +103,21 @@ pub struct Query {
pub start_time: u64, // unix timestamp
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub struct QueryProgram {
pub binary_name: String,
pub format: ExecutionFormat,
pub source: String, // TODO(swicki) use Url crate for this?
pub args: Vec<String>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub enum ExecutionFormat {
NativeExecutable,
Other,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct ExecutorId(pub u64);

impl From<u64> for ExecutorId {
Expand All @@ -127,23 +126,23 @@ impl From<u64> for ExecutorId {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Executor {
pub id: ExecutorId,
pub host: String,
pub format: ExecutionFormat,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Publication(pub QueryId, pub TopicId);

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Subscription(pub QueryId, pub TopicId);

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Abomonation, TypeName)]
pub struct KeeperId(pub u64);

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Abomonation, TypeName)]
pub struct Keeper {
pub id: KeeperId,
pub name: String,
Expand Down
1 change: 1 addition & 0 deletions src/strymon_runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tokio-io = "0.1"
tokio-core = "0.1.10"
tokio-process = "0.1.4"
tokio-signal = "0.1.2"
typename = "0.1"

[dependencies.strymon_communication]
path = "../strymon_communication/"
Expand Down
7 changes: 4 additions & 3 deletions src/strymon_runtime/src/coordinator/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ use std::hash::Hash;

use futures::Future;
use tokio_core::reactor::Handle;
use strymon_communication::Network;
use serde::ser::Serialize;
use typename::TypeName;

use strymon_model::*;
use strymon_rpc::coordinator::*;
use strymon_communication::Network;

use pubsub::publisher::collection::{CollectionPublisher, Mutator};

Expand Down Expand Up @@ -206,7 +207,7 @@ struct MapCollection<K, V> {
mutator: Mutator<V>,
}

impl<K: Ord, V: Serialize + Eq + Clone + 'static> MapCollection<K, V> {
impl<K: Ord, V: Serialize + TypeName + Eq + Clone + 'static> MapCollection<K, V> {
fn new(network: &Network,
handle: &Handle,
topic_id: TopicId,
Expand Down Expand Up @@ -258,7 +259,7 @@ struct Collection<T> {
mutator: Mutator<T>,
}

impl<T: Serialize + Clone + Eq + Hash + 'static> Collection<T> {
impl<T: Serialize + TypeName + Clone + Eq + Hash + 'static> Collection<T> {
fn new(network: &Network,
handle: &Handle,
topic_id: TopicId,
Expand Down
3 changes: 1 addition & 2 deletions src/strymon_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(core_intrinsics)]

extern crate libc;
#[macro_use]
extern crate log;
Expand All @@ -25,6 +23,7 @@ extern crate rand;
extern crate time;

extern crate serde;
extern crate typename;

extern crate strymon_communication;

Expand Down
4 changes: 3 additions & 1 deletion src/strymon_runtime/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use futures::Future;
use serde::ser::Serialize;
use serde::de::DeserializeOwned;

use typename::TypeName;

use strymon_communication::Network;
use strymon_communication::rpc::Outgoing;

Expand Down Expand Up @@ -108,7 +110,7 @@ pub fn execute<T, F>(func: F) -> Result<WorkerGuards<T>, String>
/// This is a helper trait to workaround the fact that Rust does not allow
/// us to implement Serde's traits for Timely's custom timestamp types.
pub trait PubSubTimestamp: Timestamp {
type Converted: Serialize + DeserializeOwned;
type Converted: Serialize + DeserializeOwned + TypeName;

fn to_pubsub(&self) -> Self::Converted;
fn from_pubsub(converted: Self::Converted) -> Self;
Expand Down
7 changes: 4 additions & 3 deletions src/strymon_runtime/src/query/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use timely_communication::{Allocate, Pull, Push};

use serde::ser::Serialize;
use futures::Future;
use typename::TypeName;

use query::{Coordinator, PubSubTimestamp};
use strymon_rpc::coordinator::*;
Expand Down Expand Up @@ -155,7 +156,7 @@ impl Coordinator {
stream: &Stream<S, D>,
partition: Partition)
-> Result<Stream<S, D>, PublicationError>
where D: ExchangeData + Serialize,
where D: ExchangeData + Serialize + TypeName,
S: Scope,
S::Timestamp: PubSubTimestamp
{
Expand All @@ -173,7 +174,7 @@ impl Coordinator {
let publication = if name.is_some() {
// local worker hosts a publication
let item = TopicType::of::<D>();
let time = TopicType::of::<S::Timestamp>();
let time = TopicType::of::<<S::Timestamp as PubSubTimestamp>::Converted>();
let schema = TopicSchema::Stream(item, time);

Some(self.publish_request(name.unwrap(), schema, addr.unwrap())?)
Expand Down Expand Up @@ -210,7 +211,7 @@ impl Coordinator {
stream: &Stream<S, (D, i32)>,
partition: Partition)
-> Result<Stream<S, (D, i32)>, PublicationError>
where D: ExchangeData + Eq + Serialize,
where D: ExchangeData + Eq + Serialize + TypeName,
S: Scope
{
let worker_id = stream.scope().index() as u64;
Expand Down
4 changes: 3 additions & 1 deletion src/strymon_runtime/src/submit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use futures::stream::Stream;

use serde::de::DeserializeOwned;

use typename::TypeName;

use strymon_communication::Network;
use strymon_communication::rpc::{Outgoing, Response};

Expand Down Expand Up @@ -72,7 +74,7 @@ impl Submitter {
}

fn get_collection<D>(&self, name: &str) -> Result<Vec<D>>
where D: DeserializeOwned + Clone
where D: DeserializeOwned + TypeName + Clone
{
let topic = self.lookup(name)?;
assert_eq!(topic.schema, TopicSchema::Collection(TopicType::of::<D>()));
Expand Down

0 comments on commit ea2d1d7

Please sign in to comment.