Streaming Data With FS2 #2436
Unanswered
SarpongAbasimi
asked this question in
Q&A
Replies: 1 comment 3 replies
|
Usually I'd recommend showing more code, including what imports you have and what codec is used for the JSON decoding. First of all, you're consuming a streaming endpoint, which will keep producing input (I assume) forever, but even if it's short-lived you shouldn't use Roughly something like this: response.body
.covary[IO]
.through(io.circe.fs2.byteStreamParser)
.evalMap(_.as[SampleTweet].liftTo[IO])
.compile
.toList
.unsafeRunSync()btw. for syntactic convenience check out |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey 👋🏿
I am trying to stream data from the twitter api
https://api.twitter.com/2/tweets/sample/streamRef -
https://developer.twitter.com/en/docs/twitter-api/tweets/sampled-stream/api-reference/get-tweets-sample-streamFor the client I have this
with sample tweet being
but when I make a request, I get this error
expected eof got '{"data...' (line 2, column 1)There isn't a comma
,after eachdata. (I think that is the reason for the error)This makes me think that I am probably not handling the stream well. Please is there a better way to handle streams in
fs2?All reactions