Hi paweł,

yes, that's an unfortunate detail of the Java API. Whatever you put in
there as the Object value it will be ignored. So, to convert your flow
you should be able to use `.<Object>mapMaterializedValue(m -> m)` to
convert the type.

Johannes


On Tue, Aug 25, 2015 at 11:19 PM, paweł kamiński <[email protected]> wrote:
> OK I give up again :)
>
> so if I have
>
> Source<Integer, BoxedUnit> source = producer.produce(10, 100);
>
>
> and encoder that transforms integer to ByteStrings
>
>
> final Flow<Integer, ByteString, BoxedUnit> encoder = Flow
>         .of(Integer.class)
>         .map(number -> {
>             final ByteStringBuilder builder = new ByteStringBuilder();
>             builder.putByte((byte) 4);
>             builder.putInt(number, ByteOrder.BIG_ENDIAN);
>
>             return builder.result();
>         })
>         .named("encoder");
>
>
> I apply transformation as Source<ByteString, BoxedUnit> data =
> source.via(encoder) but how do I get Source<ByteString, Object> data.
>
>
> Flow.of(Integer.class) creates Flow that materializes to BoxUnit
>
>
> what Object stands for?
>
>
> On Tuesday, 11 August 2015 09:44:15 UTC+2, Johannes Rudolph wrote:
>>
>> Hi paweł,
>>
>> you are on the right track. You need to provide the data as a
>> `Source<ByteString, Object>`. Then, you can create a response like this:
>>
>> Source<ByteString, Object> data = ...
>> HttpResponse response =
>> HttpResponse.create().withEntity(HttpEntities.createChunked(contentType,
>> data));
>>
>> If you know the length of the data (i.e. the aggregated number of octets
>> in all the ByteStrings the Source provides), you can also use
>>
>> HttpEntityies.create(contentType, length, data)
>>
>> to create a (non-chunked) streamed default entity.
>>
>> HTH
>> Johannes
>>
>>
>>
>> On Monday, August 10, 2015 at 10:38:40 PM UTC+2, paweł kamiński wrote:
>> hi,
>> probably again I ve overlooked it in documentation but I cannot find a way
>> to respond to a http request with streamed response. probably
>> HttpEntityChunked should be used but again I cannot figure out how to set
>> entities and flows correctly.
>>
>>
>> this is basic example
>>
>>
>> private RouteResult getEvents(RequestContext ctx)
>> {
>>
>> final Source<Integer, BoxedUnit> source = producer.produce(10, 100);
>> return ctx.complete(HttpResponse.create());
>> }
>>
>>
>> thanks for any hint on that
>
> --
>>>>>>>>>>> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/kHNRr-Vqhzc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.



-- 
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to