stellar-rust-sdk icon indicating copy to clipboard operation
stellar-rust-sdk copied to clipboard

Determine how we should handle streaming end points

Open choubacha opened this issue 7 years ago • 7 comments
trafficstars

Stellar has the ability to hold a stable connection and stream events as they occur. I'm not sure where we need this functionality yet but we need to devise how we can handle this in the client: https://www.stellar.org/developers/horizon/reference/responses.html#streaming

I believe that hyper supports the event-stream content type, but I'm not sure how it does it. I'm also not sure we need it in our server implementation and we can delay implementation until it's needed.

choubacha avatar Mar 21 '18 16:03 choubacha

One solution that doesn't use streaming would be to implement an InfiniteIter that doesn't terminate when nothing is returned, but instead sleeps and then re-queries. It could be modeled after the current Iter./

choubacha avatar May 09 '18 16:05 choubacha

Cool, checked out the repeat method for iter: https://doc.rust-lang.org/std/iter/fn.repeat.html

Is the idea here to basically poll an endpoint, sort of like I do for the meetup bot here: https://github.com/robertDurst/tipmebch/blob/master/meetup_bot/src/meetup/stellar/mod.rs#L14

robertDurst avatar May 14 '18 00:05 robertDurst

Any more thoughts here? Once I finish #215 I'd be interested in this since I may not be much help w/ XDR.

Started working in Go SDK @work and here is how it does streaming: https://github.com/stellar/go/blob/master/clients/horizon/client.go#L298

robertDurst avatar Jun 06 '18 22:06 robertDurst

@robertDurst That actually kinda makes me think that it doesn't work with an open connection, seems like it's just the SSE format that's it providing.

My issue with it is that I can't seem to keep the connection open, but maybe i wasn't at the end of the cursor?

choubacha avatar Jun 06 '18 23:06 choubacha

To confirm, it doesn't continuously ping? It instead opens a connection and continuously receives a stream of data?

Do you have an example? I was messing around with reqwest yesterday.

robertDurst avatar Jun 06 '18 23:06 robertDurst

Oh, I had an example at one point. It made the first request but didn't keep streaming content. The go implementation appears to loop making a new request each time. Maybe it hangs on the connection when you are at the last cursor?

choubacha avatar Jun 06 '18 23:06 choubacha

Hmmm... not quite sure. Will give a closer look

robertDurst avatar Jun 06 '18 23:06 robertDurst