Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 07 2018 13:58
    @tobz banned @SoniEx2
  • Aug 01 2018 23:32

    carllerche on gh-pages

    Documentation for tokio-rs/toki… (compare)

  • Aug 01 2018 23:29

    carllerche on master

    Deprecate tokio-proto. (#209) (compare)

  • Aug 01 2018 23:29
    carllerche closed #209
  • Aug 01 2018 19:10
    tobz commented #207
  • Aug 01 2018 19:08
    tobz synchronize #209
  • Aug 01 2018 19:00
    tobz commented #209
  • Aug 01 2018 19:00
    tobz opened #209
  • Jul 26 2018 14:13
    upsuper opened #208
  • Jul 20 2018 03:16
    driftluo edited #207
  • Jul 20 2018 03:15
    driftluo opened #207
  • Jun 15 2018 13:04
    ignatenkobrain opened #206
  • Jun 12 2018 01:41
    rphmeier commented #205
  • Jun 12 2018 01:41
    rphmeier edited #205
  • Jun 12 2018 01:40
    rphmeier commented #205
  • Jun 12 2018 01:40
    rphmeier closed #205
  • Jun 12 2018 01:40
    rphmeier commented #205
  • Jun 12 2018 01:40
    rphmeier commented #205
  • Jun 12 2018 01:36
    rphmeier opened #205
  • Jun 01 2018 13:55
    flosse commented #202
Jasper
@jbg
looking at the code i don't think it would be too bad to adapt to async
Michal 'vorner' Vaner
@vorner
The signature would have to change, but yes, with the async/await support, it should be mostly easy to do. Maybe some kind of macro to generate both versions and have the support directly in tokio-json would be the best option.
Anyway, if you want to have a look at the old code, I'll try to find it in the old repo
Jasper
@jbg
since it doesn't need an executor it could be a futures/async-await feature on serde_json
then it can work on any async runtime
although, it's stream processing
and we sadly don't have a Stream trait in std
so yeah i guess it needs to be runtime-specific for now
Jasper
@jbg
anyway the tokio-io codec setup is really nice for this kind of thing so runtime-specific is no real loss ;)
ah, this is newline-delimited?
Michal 'vorner' Vaner
@vorner
Is it? mmnt, I have both in that file I think, maybe I've picked the wrong one.
Jasper
@jbg
why not use LinesCodec?
ah i found it further down
nice
Michal 'vorner' Vaner
@vorner
It didn't exist at the time AFAIK.
This is really old code and while it might have been updated a bit, I never had motivation to migrate away to the LinesCodec
Jasper
@jbg
fair enough, it ain't broke and all that
Michal 'vorner' Vaner
@vorner
And I no longer use that code and there were no bug reports… so maybe it just became obsolete.
Christopher Andronikos
@candronikos
Hi All, is it possible have a loop wait for a change of a value, i.e. a bool? Or would I have to write a custom future for that?
matrixbot
@matrixbot
AkhIL https://github.com/paritytech/jsonrpsee seems to be active
Christopher Andronikos
@candronikos
I should elaborate on my question:
I'm trying to create a shared resource which in this case would be a reqwest::Client and use a request/response model of communication as described here. The loop that receives requests, is supposed authenticate with a remote server before it and subsequent requests are able to be made. However, the tests almost always fail. Usually only the first one to run passes and once the server is authenticated, nothing else works. There are some outliers where 5 out of the 6 work, however, I'm sure this can be done in a much more robust way.
The client mpsc::TX is initialised as a static global variable for the purpose of the tests. Any tips on a way forward here?
madmaxio
@madmaxio
@candronikos You better share the code
nicolaiunrein
@nicolaiunrein
@candronikos have a look at oneshot channels
Vitaly Shukela
@vi
What is status of tokio-codec in Tokio 2 world? Is it deprecated or just not ready?
Vitaly Shukela
@vi
@pimeys Thanks for the reply.
David Holroyd
@dholroyd

I'm receiving UDP packets just fine (although without proper error handling yet),

    let mut decoder = Decoder::new(buffer_pool.clone(), recv);
    loop {
        let mut pk = buffer_pool.allocate().expect("allocating main buffer");
        let size = udp_sock.recv(pk.payload_mut()).await?;
        pk.truncate(size);
        decoder
            .add_main_packet(pk)
            .expect("decoding main packet");
    }

I'd like to extend this to be able to receive UDP packets from multiple sockets in parallel and (remembering which tokio::net::UdpSocket a packet came from) feed them all into my Decoder instance as they arrive

looks like maybe a job for select_all combinator
I am not certain what attention to give the "list of all the remaining futures" which select_all will produce
...i.e. could I just carry on back around the loop as above or will there be a performance or correctness problem?
David Holroyd
@dholroyd
(I am giving select_all a go at the moment)
David Holroyd
@dholroyd
ah, no, probably I want select!
David Holroyd
@dholroyd
:heavy_check_mark: select!
    let mut decoder = Decoder::new(buffer_pool.clone(), recv);

    loop {
        select! {
            pk = async {
                let mut pk = buffer_pool.allocate().expect("allocating main buffer");
                main_sock.recv(pk.payload_mut())
                    .await
                    .map(|size| {
                        pk.truncate(size);
                        pk
                    })
            }.fuse() => decoder.add_main_packet(pk?).expect("decoding main packet"),
            ...etc...
        }
Diggory Blake
@Diggsey
is calling try_send on a freshly cloned mpsc::Sender guaranteed to succeed if the channel is open?
Kihomenethoth
@taylorcenters

Hey I'm looking for some help with an error I'm getting for this block of code
let mut stream = client .event_stream(Request::new(receiver)) .await .map_err(|e| panic!("failed to start event stream: {}", e)) .unwrap() .into_inner();

the error is

error[E0277]: the trait bound tonic::request::Request<futures_channel::mpsc::UnboundedReceiver<azure_functions_shared::rpc::StreamingMessage>>: tonic::request::IntoStreamingRequest is not satisfied
--> azure-functions/src/worker.rs:115:31
|
115 | .event_stream(Request::new(receiver))
| ^^^^^^^^^^^^^^^^^^^^^^ the trait tonic::request::IntoStreamingRequest is not implemented for tonic::request::Request<futures_channel::mpsc::UnboundedReceiver<azure_functions_shared::rpc::StreamingMessage>>
|
= help: the following implementations were found:
<tonic::request::Request<T> as tonic::request::IntoStreamingRequest>

where event_stream is a generated function from protobuf with the parameter

pub async fn event_stream( &mut self, request: impl tonic::IntoStreamingRequest<Message = super::StreamingMessage>, ) -> Result<tonic::Response<tonic::codec::Streaming<super::StreamingMessage>>, tonic::Status>

But from what I can tell tonic::request::Request does implement IntoStreamingRequest

nicolaiunrein
@nicolaiunrein
Well the docs state IntoStreamingRequest is implemented for all Request<T> where T: stream + send + sync + 'static. Make sure your type holds this bound. To check you could define a function which accepts such a Request and try to pass your Request::new(receiver) in to see if it fulfills the requirements.
lemonxah
@lemonxah
hi
anyone using tokio with rocket.rs?
Vitaly Shukela
@vi
Is there something like a weaker tokio::task::yield_now that does not immediately yield a task, but depletes one point from that 128 fuel counter that is used for all IO operations and yields only if it zero?
Rishi Desai
@apache8080

With rust futures is it possible to string together multiple different actions instead of calling await and then unwrapping the result.
To give more context, I have a tokio TcpStream that I want to connect to, write some data on, and then if the write succeeds read data across the socket. If any of these have errors I just want to catch the error and print.
in pseudocode I would want to do something like this:

stream_future = TcpStream::connect(url).write_all(some_msg).read_to_string(output).if_err(print err and continue)
join!(stream_future);

The reason I want to do it this way is I have a list of TCP servers I want to connect to and try the same thing and I don't want a single bad connection to kill the whole program. I know how to make this work by just unwrapping and handling the errors using match statements but I was wondering if there was a cleaner way to do this.

matrixbot
@matrixbot
tanriol Rishi Desai (Gitter): Do you mean that you want to avoid match on every return value?
Rishi Desai
@apache8080
Sort of
matrixbot
@matrixbot
tanriol The ? operator in async functions is quite useful for that.
Michal 'vorner' Vaner
@vorner
Hello. Recently, we have migrated from tokio 0.1/hyper 0.12 to tokio 0.2/hyper 0.13 (yes, a bit late to the game). And suddenly a downstream service tells us that 99% latency raised from ~1ms to 40ms (almost exactly, across multiple servers and keeping the graph flat there). It's probably specific to our service, but I just wanted to ask if someone had a similar experience.
ugurcan377
@ugurcan377

Hello, I've been trying to use a reciever of a channel inside of select and getting this error

no method named `poll` found for struct `std::pin::Pin<&mut futures::channel::mpsc::UnboundedReceiver<()>>` in the current scope
method not found in `std::pin::Pin<&mut futures::channel::mpsc::UnboundedReceiver<()>>`

I am probably doing something wrong here but couldn't find out what.

let mut lock_rx = data.add_handle_to_queue(&req.key, &new_handle);
    let fu = async move {
        loop {
            let lock_expiry = time::delay_for(std::time::Duration::from_millis(
                data.get_lock_remaining_time(&req.key)as u64));
            tokio::select! {
                _ = lock_expiry => {println!("Lock expired")},
                _ = lock_rx => {},
            }

Thank you for any assistance.

3 replies