Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 49be423

Browse files
authored
Remove dependency on rust nightly (#68)
Upgrade to tacho 0.4.1 so that rust nightly is not required. RUSTFMT FOR THE RUSTFMT DIETY! Apply new rustfmt style to the whole repo.
1 parent 3d7771a commit 49be423

File tree

24 files changed

+505
-421
lines changed

24 files changed

+505
-421
lines changed

Cargo.lock

Lines changed: 25 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "linkerd-tcp"
33
description = "A native TCP proxy for the linkerd service mesh"
4-
version = "0.1.0"
4+
version = "0.1.1"
55
authors = [
66
"Oliver Gould <[email protected]>",
77
"Steve Jenson <[email protected]>",
@@ -29,7 +29,7 @@ serde_derive = "1.0"
2929
serde_json = "1.0"
3030
serde_yaml = "0.7"
3131
# tacho = { path = "../tacho" }
32-
tacho = "0.4"
32+
tacho = "0.4.1"
3333
tokio-core = "0.1"
3434
tokio-io = "0.1"
3535
tokio-service = "0.1"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Status: _beta_
2727

2828
1. Install [Rust and Cargo][install-rust].
2929
2. Run [namerd][namerd]. `./namerd.sh` fetches, configures, and runs namerd using a local-fs-backed discovery (in ./tmp.discovery).
30-
3. From this repository, run: `rustup run nightly cargo run -- example.yml`
30+
3. From this repository, run: `cargo run -- example.yml`
3131

3232
We :heart: pull requests! See [CONTRIBUTING.md](CONTRIBUTING.md) for info on
3333
contributing changes.

src/admin.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ pub struct Admin {
2323
type RspFuture = Box<Future<Item = Response, Error = hyper::Error>>;
2424

2525
impl Admin {
26-
pub fn new(prometheus: Rc<RefCell<String>>,
27-
closer: Closer,
28-
grace: Duration,
29-
reactor: Handle,
30-
timer: Timer)
31-
-> Admin {
26+
pub fn new(
27+
prometheus: Rc<RefCell<String>>,
28+
closer: Closer,
29+
grace: Duration,
30+
reactor: Handle,
31+
timer: Timer,
32+
) -> Admin {
3233
Admin {
3334
closer: Rc::new(RefCell::new(Some(closer))),
3435
prometheus,

src/app.rs

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,22 @@ impl AppConfig {
106106
let mut resolvers = VecDeque::with_capacity(self.routers.len());
107107
for config in self.routers.drain(..) {
108108
let mut r = config.into_router(buf.clone(), &metrics)?;
109-
let e = r.resolver_executor
110-
.take()
111-
.expect("router missing resolver executor");
109+
let e = r.resolver_executor.take().expect(
110+
"router missing resolver executor",
111+
);
112112
routers.push_back(r);
113113
resolvers.push_back(e);
114114
}
115115

116116
// Read the admin server configuration and bundle it an AdminRunner.
117117
let admin = {
118118
let addr = {
119-
let ip = self.admin
120-
.as_ref()
121-
.and_then(|a| a.ip)
122-
.unwrap_or_else(localhost_addr);
123-
let port = self.admin
124-
.as_ref()
125-
.and_then(|a| a.port)
126-
.unwrap_or(DEFAULT_ADMIN_PORT);
119+
let ip = self.admin.as_ref().and_then(|a| a.ip).unwrap_or_else(
120+
localhost_addr,
121+
);
122+
let port = self.admin.as_ref().and_then(|a| a.port).unwrap_or(
123+
DEFAULT_ADMIN_PORT,
124+
);
127125
net::SocketAddr::new(ip, port)
128126
};
129127
let grace = {
@@ -150,9 +148,9 @@ impl AppConfig {
150148
};
151149

152150
Ok(App {
153-
routers: routers,
154-
admin: admin,
155-
})
151+
routers: routers,
152+
admin: admin,
153+
})
156154
}
157155
}
158156

@@ -190,10 +188,11 @@ pub struct RouterConfig {
190188

191189
impl RouterConfig {
192190
/// Consumes and validates this configuration to produce a router initializer.
193-
fn into_router(mut self,
194-
buf: Rc<RefCell<Vec<u8>>>,
195-
metrics: &tacho::Scope)
196-
-> Result<RouterSpawner> {
191+
fn into_router(
192+
mut self,
193+
buf: Rc<RefCell<Vec<u8>>>,
194+
metrics: &tacho::Scope,
195+
) -> Result<RouterSpawner> {
197196
let metrics = metrics.clone().labeled("rt", self.label);
198197

199198
// Each router has its own resolver/executor pair. The resolver is used by the
@@ -225,9 +224,9 @@ impl RouterConfig {
225224
}
226225

227226
Ok(RouterSpawner {
228-
servers: servers,
229-
resolver_executor: Some(resolver_exec),
230-
})
227+
servers: servers,
228+
resolver_executor: Some(resolver_exec),
229+
})
231230
}
232231
}
233232

@@ -243,9 +242,11 @@ impl RouterSpawner {
243242
/// Returns successfully if all servers have been bound and spawned correctly.
244243
pub fn spawn(mut self, reactor: &Handle, timer: &Timer) -> Result<()> {
245244
while let Some(unbound) = self.servers.pop_front() {
246-
info!("routing on {} to {}",
247-
unbound.listen_addr(),
248-
unbound.dst_name());
245+
info!(
246+
"routing on {} to {}",
247+
unbound.listen_addr(),
248+
unbound.dst_name()
249+
);
249250
let bound = unbound.bind(reactor, timer).expect("failed to bind server");
250251
reactor.spawn(bound.map_err(|_| {}));
251252
}
@@ -313,17 +314,16 @@ impl AdminRunner {
313314
let prom_export = Rc::new(RefCell::new(String::with_capacity(8 * 1024)));
314315
let reporting = {
315316
let prom_export = prom_export.clone();
316-
timer
317-
.interval(metrics_interval)
318-
.map_err(|_| {})
319-
.for_each(move |_| {
320-
let report = reporter.take();
321-
let mut prom_export = prom_export.borrow_mut();
322-
prom_export.clear();
323-
tacho::prometheus::write(&mut *prom_export, &report)
324-
.expect("error foramtting metrics for prometheus");
325-
Ok(())
326-
})
317+
timer.interval(metrics_interval).map_err(|_| {}).for_each(
318+
move |_| {
319+
let report = reporter.take();
320+
let mut prom_export = prom_export.borrow_mut();
321+
prom_export.clear();
322+
tacho::prometheus::write(&mut *prom_export, &report)
323+
.expect("error foramtting metrics for prometheus");
324+
Ok(())
325+
},
326+
)
327327
};
328328
handle.spawn(reporting);
329329

@@ -336,12 +336,10 @@ impl AdminRunner {
336336
let server =
337337
admin::Admin::new(prom_export, closer, grace, handle.clone(), timer.clone());
338338
let http = Http::new();
339-
listener
340-
.incoming()
341-
.for_each(move |(tcp, src)| {
342-
http.bind_connection(&handle, tcp, src, server.clone());
343-
Ok(())
344-
})
339+
listener.incoming().for_each(move |(tcp, src)| {
340+
http.bind_connection(&handle, tcp, src, server.clone());
341+
Ok(())
342+
})
345343
};
346344
reactor.run(serving).unwrap();
347345

0 commit comments

Comments
 (0)