Skip to content

Commit

Permalink
chore: some cleanup after cargo fixes
Browse files Browse the repository at this point in the history
mostly just migrating off #[macro_use] extern crates except for
error_chain/slog which assume the #[macro_use] blanket imports
  • Loading branch information
pjenvey committed Jan 7, 2019
1 parent 909965f commit 6c11821
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 68 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use std::time::Duration;

use cadence::{prelude::*, StatsdClient};
use error_chain::ChainedError;
use futures::future;
use futures::future::Either;
use futures::sync::mpsc;
use futures::sync::oneshot::Receiver;
use futures::AsyncSink;
use futures::{future, try_ready};
use futures::{Async, Future, Poll, Sink, Stream};
use reqwest::r#async::Client as AsyncClient;
use rusoto_dynamodb::UpdateItemOutput;
use sentry;
use sentry::integrations::error_chain::event_from_error_chain;
use state_machine_future::RentToOwn;
use state_machine_future::{transition, RentToOwn, StateMachineFuture};
use tokio_core::reactor::Timeout;
use uuid::Uuid;
use woothee::parser::Parser;
Expand Down
1 change: 1 addition & 0 deletions src/db/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use cadence::{Counted, StatsdClient};
use chrono::Utc;
use futures::{future, Future};
use futures_backoff::retry_if;
use matches::matches;
use rusoto_dynamodb::{
AttributeValue, DeleteItemError, DeleteItemInput, DeleteItemOutput, DynamoDb, GetItemError,
GetItemInput, GetItemOutput, ListTablesInput, ListTablesOutput, PutItemError, PutItemInput,
Expand Down
4 changes: 3 additions & 1 deletion src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use uuid::Uuid;
use cadence::StatsdClient;
use futures::{future, Future};
use futures_backoff::retry_if;
use matches::matches;
use rusoto_core::{HttpClient, Region};
use rusoto_credential::StaticProvider;
use rusoto_dynamodb::{
Expand All @@ -19,10 +20,11 @@ use serde_dynamodb;
mod macros;
mod commands;
mod models;
mod util;

use crate::errors::*;
use crate::protocol::Notification;
use crate::server::{Server, ServerOptions};
mod util;
use crate::util::timing::sec_since_epoch;

use self::commands::FetchMessageResponse;
Expand Down
4 changes: 3 additions & 1 deletion src/db/models.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::cmp::min;
use std::collections::{HashMap, HashSet};
use std::result::Result as StdResult;
use uuid::Uuid;

use lazy_static::lazy_static;
use regex::RegexSet;
use serde::Serializer;
use serde_derive::{Deserialize, Serialize};
use uuid::Uuid;

use crate::db::util::generate_last_connect;
use crate::errors::*;
Expand Down
52 changes: 1 addition & 51 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,63 +43,13 @@
//! Otherwise be sure to check out each module for more documentation!
// `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
use base64;

use cadence;


use config;


#[macro_use]
extern crate futures;

use hex;
use httparse;
use hyper;
#[macro_use]
extern crate lazy_static;

#[macro_use]
extern crate matches;
use mozsvc_common;



use reqwest;



#[macro_use]
extern crate sentry;

#[macro_use]
extern crate serde_derive;
use serde_dynamodb;
#[macro_use]
extern crate serde_json;
extern crate error_chain;
#[macro_use]
extern crate slog;
use slog_async;

#[macro_use]
extern crate slog_scope;
use slog_stdlog;
use slog_term;
#[macro_use]
extern crate state_machine_future;
use time;

use tokio_io;



use tungstenite;
use uuid;


#[macro_use]
extern crate error_chain;

#[macro_use]
mod db;
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ extern crate serde_derive;

use chan_signal;


use std::env;

use chan_signal::Signal;
Expand Down
1 change: 1 addition & 0 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use std::collections::HashMap;
use std::str::FromStr;

use serde_derive::{Deserialize, Serialize};
use serde_json;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion src/server/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! many other options for now!
use bytes::BytesMut;
use futures::{Future, Poll};
use futures::{try_ready, Future, Poll};
use httparse;
use tokio_core::net::TcpStream;
use tokio_io::AsyncRead;
Expand Down
11 changes: 6 additions & 5 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ use base64;
use cadence::StatsdClient;
use fernet::{Fernet, MultiFernet};
use futures::sync::oneshot;
use futures::task;
use futures::{task, try_ready};
use futures::{Async, AsyncSink, Future, Poll, Sink, StartSend, Stream};
use hex;
use hyper::server::Http;
use hyper::{self, StatusCode};
use openssl::hash;
use openssl::ssl::SslAcceptor;
use reqwest;
use sentry;
use sentry::integrations::panic::register_panic_handler;
use serde_json;
use sentry::{self, integrations::panic::register_panic_handler, sentry_crate_release};
use serde_json::{self, json};
use time;
use tokio_core::net::TcpListener;
use tokio_core::reactor::{Core, Handle, Timeout};
Expand All @@ -40,7 +39,9 @@ use crate::errors::*;
use crate::errors::{Error, Result};
use crate::http;
use crate::logging;
use crate::protocol::{BroadcastValue, ClientMessage, Notification, ServerMessage, ServerNotification};
use crate::protocol::{
BroadcastValue, ClientMessage, Notification, ServerMessage, ServerNotification,
};
use crate::server::dispatch::{Dispatch, RequestType};
use crate::server::metrics::metrics_from_opts;
use crate::server::webpush_io::WebpushIo;
Expand Down
2 changes: 2 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::net::ToSocketAddrs;

use config::{Config, ConfigError, Environment, File};
use fernet::Fernet;
use lazy_static::lazy_static;
use mozsvc_common;
use serde_derive::Deserialize;

lazy_static! {
static ref HOSTNAME: String = mozsvc_common::get_hostname().expect("Couldn't get_hostname");
Expand Down
7 changes: 4 additions & 3 deletions src/util/megaphone.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::errors::Result;
use std::collections::HashMap;
use std::time::Duration;

use crate::protocol::BroadcastValue;

use reqwest;
use serde_derive::{Deserialize, Serialize};

use crate::errors::Result;
use crate::protocol::BroadcastValue;

// A Broadcast entry Key in a BroadcastRegistry
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]
Expand Down
6 changes: 3 additions & 3 deletions src/util/send_all.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use futures::stream::Fuse;
use futures::{Async, AsyncSink, Future, Poll, Sink, Stream};
use futures::{try_ready, Async, AsyncSink, Future, Poll, Sink, Stream};

// This is a copy of `Future::forward`, except that it doesn't close the sink
// when it's finished.
Expand Down Expand Up @@ -52,7 +52,7 @@ where

fn try_start_send(&mut self, item: T::Item) -> Poll<(), U::SinkError> {
debug_assert!(self.buffered.is_none());
if let AsyncSink::NotReady(item) = r#try!(self.sink_mut().start_send(item)) {
if let AsyncSink::NotReady(item) = self.sink_mut().start_send(item)? {
self.buffered = Some(item);
return Ok(Async::NotReady);
}
Expand All @@ -77,7 +77,7 @@ where
}

loop {
match r#try!(self.stream_mut().poll()) {
match self.stream_mut().poll()? {
Async::Ready(Some(item)) => try_ready!(self.try_start_send(item)),
Async::Ready(None) => {
try_ready!(self.sink_mut().poll_complete());
Expand Down

0 comments on commit 6c11821

Please sign in to comment.