Hi Thibault,

I do this kind of thing with Source.fromIterator(...) passing it an iterator obtained from a java stream.

In your case, it would look something like:

Source<UUID, ?> source = Source.fromIterator( () ->

    Stream.generate( ()->

        UUID.randomUUID()

    ).iterator()

).take(n);

then I stream it out as per:

http://doc.akka.io/docs/akka-http/current/java/http/routing-dsl/source-streaming-support.html#simple-csv-streaming-example

The conversion from the domain object (UUID in your case) to ByteString happens in the function passed when creating the Marshaller as in the CSV example in the doc section above (I just use Jackson.marshaller() in my case)

Happy to learn if there's a better way to do this.

Cheers,

Michal


On 20/04/17 08:56, Thibault Meyer wrote:
Hi,

I trying akka-http (version 10.x) by creating a small API who generate UUID on demand. For a bulk UUID creation (ex: //uuid1/5000/ to get 5000 UUID v1), I would like to return a chunked response to avoir building a list of xxxx item on memory.

From Play 2.5 I usually using final Source<ByteString, ?> source = Source.fromGraph(...) but I don't find how to do this with akka-http and akka-stream.

Do you have any idea how to do this ?
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com <mailto:akka-user+unsubscr...@googlegroups.com>. To post to this group, send email to akka-user@googlegroups.com <mailto:akka-user@googlegroups.com>.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

--
Signature
<http://www.openbet.com/>         Michal Borowiecki
Senior Software Engineer L4
        T:      +44 208 742 1600

        
        +44 203 249 8448

        
        
        E:      michal.borowie...@openbet.com
        W:      www.openbet.com <http://www.openbet.com/>

        
        OpenBet Ltd

        Chiswick Park Building 9

        566 Chiswick High Rd

        London

        W4 5XT

        UK

        
<https://www.openbet.com/email_promo>

This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@openbet.com <mailto:postmas...@openbet.com> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by OpenBet for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. OpenBet Ltd. Registered Office: Chiswick Park Building 9, 566 Chiswick High Road, London, W4 5XT, United Kingdom. A company registered in England and Wales. Registered no. 3134634. VAT no. GB927523612

--
     Read the docs: http://akka.io/docs/
     Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
     Search the archives: https://groups.google.com/group/akka-user
--- You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to