stellar-rust-sdk
stellar-rust-sdk copied to clipboard
Determine how we should handle streaming end points
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.
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./
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
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 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?
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.
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?
Hmmm... not quite sure. Will give a closer look