Use Ack for Answers with Spray

I am using a mudguard 1.2.1.

I transfer large files from / to the repository, I use both chunked requests and chunked answers for this.

For chunk requests, I use the built-in ack mechanism for my actor to make sure each fragment is written before sending more:

connection ! MessageChunk(data).withAck(ChunkSent)

connectionis an IO actor provided by Spray and Akka, then I can wait ChunkSentbefore sending the next snippet. Good.

I'm struggling to reproduce the same behavior with alternating answers. I can send mine HttpRequestand then receive ChunkedResponseStart, and then a bunch, MessageChunkand finally, ChunkedMessageEndbut is there a way to make Spray wait for me to send ack after each MessageChunkbefore sending the next one?

Edit: just to be a little clearer: I use a spray can as a client in this case, I am not a server, the server is the repository I mentioned earlier.

+4
source share
1 answer

Well put the question. Currently, you cannot force the spray (1.x.1) to wait for Acks before continuing to read.

Tcp.SuspendReading Tcp.ResumeReading ( ), TCP- Akka IO . , Acking ( , ) SuspendReading/ResumeReading , - .

, 1) , , 2) TCP-, .

, :

  • Akka IO " pull", TCP- - , Tcp.ResumeReading ( Ack). (, , ).
  • , Akka HTTP, - . , API ( , -), HTTP . , .
+3

Source: https://habr.com/ru/post/1532536/


All Articles