profile
viewpoint
Kanishkar J kanishkarj Bangalore https://kanishkarj.github.io/ CSE Undergrad, IIT Indore

startedkaran/Projects

started time in 4 days

startedmattnenterprise/rust-pop3

started time in 13 days

startedpingcap/talent-plan

started time in 15 days

fork kanishkarj/rust-mbedtls

Idiomatic Rust wrapper for MbedTLS

fork in 16 days

startedflosse/rust-web-framework-comparison

started time in 20 days

startedcha87de/docker-skeleton

started time in a month

startedfennerm/flashfocus

started time in a month

startedKocal/vue-web-extension

started time in a month

starteddenji/awesome-http-benchmark

started time in 2 months

startedbrndnmtthws/conky

started time in 2 months

PublicEvent
PublicEvent

issue commenttokio-rs/gsoc

Tokio console

@carllerche yeah definitely :)

carllerche

comment created time in 3 months

startedudacity/self-driving-car

started time in 3 months

startedtryone144/compton

started time in 3 months

issue commenttokio-rs/gsoc

Tokio console

This seems great! Part 2 didn't click me, well it's great that you pointed it out.

Yeah, I guess I could work on the subscriber part. I shall try to understand how a subscriber works so as to define the protobuf schema as soon as possible so that we could work independently.

carllerche

comment created time in 3 months

startedGenymobile/scrcpy

started time in 3 months

startedsimgrid/simgrid

started time in 3 months

pull request commentxi-editor/xi-editor

Fix external state in benchmarking (edit.rs)

Hmm, So you mean to say all the functions use the same offset update ? for eg

offset += 1

would be the offset for all the benchmarks?

kanishkarj

comment created time in 3 months

PR opened xi-editor/xi-editor

Fix external state in benchmarking (edit.rs)

This is in reference to the discussion in PR #1152. This PR fixes the external state of the iterations in the benchmarks.

+24 -5

0 comment

2 changed files

pr created time in 3 months

create barnchkanishkarj/xi-editor

branch : bench-fix

created branch time in 3 months

Pull request review commentxi-editor/xi-editor

Add more benchmarks

 fn benchmark_paste_into_line(b: &mut Bencher) {     }); } +#[bench]+fn benchmark_large_paste_into_line(b: &mut Bencher) {+    let mut text = Rope::from(build_short_lines(1_000_000));+    let insertion = build_short_lines(50_000);+    let mut offset = 25_000;+    b.iter(|| {+        text.edit(offset..=offset, &insertion);+        offset += 150;

Consider it done. :)

kanishkarj

comment created time in 3 months

fork kanishkarj/ryosuke-gatsby-blog

Static PWA React-powered portfolio and blog built with GatsbyJS

http://whoisryosuke.com

fork in 3 months

startedkremalicious/portfolio

started time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

Done I guess.

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha 720aedc1de0130a95e761266f7d3e870b98941a3

Avoid Panic

view details

push time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            let mut client_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);

Take a look now.

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha 2f56c445266875b79d9d10992075dd4e6c0fb2fa

Make client_addr into Option

view details

kanishkarj

commit sha bac4dd4803538353273ff7d7ab282e706626bc4d

Rust FMT

view details

push time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            let mut client_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);

Okayy, shall look into it.

kanishkarj

comment created time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

How is this ?

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha 8a30aeb2438442dbecced243689ae73117dfdcc2

Updates as per discussion

view details

push time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

 fn main() -> Result<(), Box<std::error::Error>> {         .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))         .for_each(move |client| {             let server = TcpStream::connect(&server_addr);+            let mut client_addr = String::new();             match client.peer_addr() {-                Ok(x) => info!(-                    message = "client connected",-                    client_addr = field::display(x)-                ),+                Ok(x) => {+                    let x = x.to_string();

Done

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            let mut client_addr = String::new();+            match client.peer_addr() {+                Ok(x) => {+                    let x = x.to_string();+                    client_addr = x;+                    info!(+                        message = "client connected",+                        client_addr = field::display(&client_addr)+                    )+                }+                Err(e) => debug!(+                    message = "could not get client info",+                    error = field::display(e)+                ),+            }++            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    })+                    .instrument(span!("client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    })+                    .instrument(span!("server_to_client"));++                client_to_server.join(server_to_client)+            });++            let msg = amounts+                .map(move |(from_client, from_server)| {+                    info!(+                        client_to_server = from_client,+                        server_to_client = from_server+                    );+                })+                .map_err(|e| {+                    // Don't panic. Maybe the client just disconnected too soon.+                    debug!(error = field::display(e));+                })+                .instrument(span!(+                    "transfer",+                    client_address = field::debug(&client_addr),+                    server_address = field::debug(&server_addr.to_string())

Done

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            let mut client_addr = String::new();+            match client.peer_addr() {+                Ok(x) => {+                    let x = x.to_string();+                    client_addr = x;+                    info!(+                        message = "client connected",+                        client_addr = field::display(&client_addr)+                    )+                }+                Err(e) => debug!(+                    message = "could not get client info",+                    error = field::display(e)+                ),+            }++            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    })+                    .instrument(span!("client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    })+                    .instrument(span!("server_to_client"));++                client_to_server.join(server_to_client)+            });++            let msg = amounts+                .map(move |(from_client, from_server)| {+                    info!(+                        client_to_server = from_client,+                        server_to_client = from_server+                    );+                })+                .map_err(|e| {+                    // Don't panic. Maybe the client just disconnected too soon.+                    debug!(error = field::display(e));+                })+                .instrument(span!(+                    "transfer",+                    client_address = field::debug(&client_addr),+                    server_address = field::debug(&server_addr.to_string())+                ));++            tokio::spawn(msg);++            Ok(())+        })+        .instrument(span!("proxy", listen_addr = field::debug(&listen_addr)));

Okay.. I think debug is more descriptive.

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!(

Ah got it.

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            let mut client_addr = String::new();+            match client.peer_addr() {+                Ok(x) => {+                    let x = x.to_string();+                    client_addr = x;+                    info!(+                        message = "client connected",+                        client_addr = field::display(&client_addr)+                    )+                }+                Err(e) => debug!(+                    message = "could not get client info",+                    error = field::display(e)+                ),+            }++            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    })+                    .instrument(span!("client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    })+                    .instrument(span!("server_to_client"));++                client_to_server.join(server_to_client)+            });++            let msg = amounts+                .map(move |(from_client, from_server)| {+                    info!(

Done

kanishkarj

comment created time in 3 months

push eventkanishkarj/xi-editor

kanishkarj

commit sha a54311305f585cf656d0d6dcb7a614ce9a0433d2

Rust FMT

view details

push time in 3 months

PR opened xi-editor/xi-editor

Add more benchmarks

Added a few more benchmarks.

+27 -0

0 comment

2 changed files

pr created time in 3 months

create barnchkanishkarj/xi-editor

branch : bench

created branch time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!(

shouldn't that be printed? also another thing to notice is that the outer most scope prints proxy_server despite being instrumented as proxy.

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha ebcda2821d7b0f49dcce8bca68aeef40566ee722

Rust FMT

view details

push time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha 0e207e43c30a005fa582010fc1d274a14bf3244c

Detailed Diagnosis

view details

push time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), +                Err(e) => debug!("error, could not get client info: {}", e)+            }+            +            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    }).instrument(span!(" client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    }).instrument(span!(" server_to_client"));++                client_to_server.join(server_to_client)+            });++            let msg = amounts+                .map(move |(from_client, from_server)| {+                    info!(+                        "client wrote {} bytes and received {} bytes",+                        from_client, from_server+                    );+                })+                .map_err(|e| {+                    // Don't panic. Maybe the client just disconnected too soon.+                    debug!("error: {}", e);+                }).instrument(span!(" transfer_complete"));

Done

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), +                Err(e) => debug!("error, could not get client info: {}", e)+            }+            +            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    }).instrument(span!(" client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    }).instrument(span!(" server_to_client"));

Done

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), 

Done!

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), +                Err(e) => debug!("error, could not get client info: {}", e)+            }+            +            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    }).instrument(span!(" client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    }).instrument(span!(" server_to_client"));

Done!

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!(

I mean the Ok(x) => info!(

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here :+https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace::field;+use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| debug!(msg = "error accepting socket", error = field::display(e)))+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!(

Ah, that's because no events are actually being recorded inside that span. If this wasn't the case (i.e. if we had enabled events emitted by tokio or another dependency, or if we added events in that span) we would see it in the logs as well.

How about this ?

kanishkarj

comment created time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), +                Err(e) => debug!("error, could not get client info: {}", e)+            }+            +            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    }).instrument(span!(" client_to_server"));

Done

kanishkarj

comment created time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

I was not able to resolve the warnings as they were in other crates, or not where I could really fix it. I could look into fixing other warnings but I guess it should be another PR. But, is every other thing okay, @hawkw ?

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha d39177592ba8e0a29feb46065b90f836d23ff3bb

Enable warnings

view details

push time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

Okay, I shall look into it. Thanks a lot though!

kanishkarj

comment created time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

why is my build failing with rust-1.26.0 ? And what can I do to fix it?

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha d99da2dc09983f079ddbc10e6ccde8ed314f7a80

Rust FMT

view details

push time in 3 months

pull request commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

I have made all the changes as discussed above.

kanishkarj

comment created time in 3 months

push eventkanishkarj/tokio-trace-nursery

kanishkarj

commit sha cc7882b44c24bace788de92b2166b8dea8de4c16

Get more diagnostics

view details

push time in 3 months

Pull request review commenttokio-rs/tokio-trace-nursery

Tokio trace instrumentation example

+/*+This example has been taken and modified from here : +https://raw.githubusercontent.com/tokio-rs/tokio/master/tokio/examples/proxy.rs+*/++#![deny(warnings)]++extern crate futures;+extern crate tokio;+#[macro_use]+extern crate tokio_trace;+extern crate tokio_trace_fmt;+extern crate tokio_trace_futures;++use tokio_trace_futures::Instrument;++use std::env;+use std::io::{self, Read, Write};+use std::net::{Shutdown, SocketAddr};+use std::sync::{Arc, Mutex};++use tokio::io::{copy, shutdown};+use tokio::net::{TcpListener, TcpStream};+use tokio::prelude::*;++fn main() -> Result<(), Box<std::error::Error>> {+    let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string());+    let listen_addr = listen_addr.parse::<SocketAddr>()?;++    let server_addr = env::args().nth(2).unwrap_or("127.0.0.1:3000".to_string());+    let server_addr = server_addr.parse::<SocketAddr>()?;++    // Create a TCP listener which will listen for incoming connections.+    let socket = TcpListener::bind(&listen_addr)?;+    println!("Listening on: {}", listen_addr);+    println!("Proxying to: {}", server_addr);++    let done = socket+        .incoming()+        .map_err(|e| {+            debug!("error accepting socket; error = {:?}", e)+        })+        .for_each(move |client| {+            let server = TcpStream::connect(&server_addr);+            match client.peer_addr() {+                Ok(x) => info!("client connected {}", x), +                Err(e) => debug!("error, could not get client info: {}", e)+            }+            +            let amounts = server.and_then(move |server| {+                // Create separate read/write handles for the TCP clients that we're+                // proxying data between. Note that typically you'd use+                // `AsyncRead::split` for this operation, but we want our writer+                // handles to have a custom implementation of `shutdown` which+                // actually calls `TcpStream::shutdown` to ensure that EOF is+                // transmitted properly across the proxied connection.+                //+                // As a result, we wrap up our client/server manually in arcs and+                // use the impls below on our custom `MyTcpStream` type.+                let client_reader = MyTcpStream(Arc::new(Mutex::new(client)));+                let client_writer = client_reader.clone();+                let server_reader = MyTcpStream(Arc::new(Mutex::new(server)));+                let server_writer = server_reader.clone();++                // Copy the data (in parallel) between the client and the server.+                // After the copy is done we indicate to the remote side that we've+                // finished by shutting down the connection.+                let client_to_server = copy(client_reader, server_writer)+                    .and_then(|(n, _, server_writer)| {+                        info!(size = n);+                        shutdown(server_writer).map(move |_| n)+                    }).instrument(span!(" client_to_server"));++                let server_to_client = copy(server_reader, client_writer)+                    .and_then(|(n, _, client_writer)| {+                        info!(size = n);+                        shutdown(client_writer).map(move |_| n)+                    }).instrument(span!(" server_to_client"));++                client_to_server.join(server_to_client)+            });++            let msg = amounts+                .map(move |(from_client, from_server)| {+                    info!(+                        "client wrote {} bytes and received {} bytes",+                        from_client, from_server+                    );+                })+                .map_err(|e| {+                    // Don't panic. Maybe the client just disconnected too soon.+                    debug!("error: {}", e);+                }).instrument(span!(" transfer_complete"));++            tokio::spawn(msg);++            Ok(())+        });

I didn't instrument that because for some reason that was not being printed out. This is the output after I made the changes :

 INFO proxy_server: client connected client_addr=127.0.0.1:45762
 INFO transfer:client_to_server: proxy_server: size=149
 INFO transfer:server_to_client: proxy_server: size=138
 INFO transfer: proxy_server: client_to_server=149 server_to_client=138
kanishkarj

comment created time in 3 months

more