Re: [akka-user] Get ActorSystem as part of a stream materialization process

2016-08-01 Thread oleksiys
Thank you Konrad,
it's exactly what I needed!

WBR,
Alexey

On Saturday, July 30, 2016 at 3:56:58 PM UTC-7, Konrad Malawski wrote:
>
> (feel free to copy paste the entire impl and use as-is if you want to btw)
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 31 July 2016 at 00:52:56, Konrad Malawski (konrad@lightbend.com 
> ) wrote:
>
> I like the idea, this can indeed be very useful!
> We'll see what the rest of the team has to say about it.
>
> I took a shot at implementing it actually, so here it is:
> https://github.com/akka/akka/pull/21076
>
> No guarantees about bug-free ness, but it seems rather complete ;-)
>
>
> It also shows of how awesome GraphStage really is, esp. with it's 
> StageActor feature which we'll blog about more in the near future.
> Just yesterday we published a post introducing GraphStage a bit from a 
> birds view btw: 
> http://blog.akka.io/streams/2016/07/30/mastering-graph-stage-part-1
> Track the blog if you want to learn interesting stuff about internals like 
> that :-)
>
>
> Happy hakking!
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 30 July 2016 at 23:19:17, Alexey S (kvr...@gmail.com ) 
> wrote:
>
> I'm trying to bind stream life-cycle to an actor life-cycle (let's call it 
> master actor). In a sense that if the stream is destroyed - the master 
> actor receives some Termination message but stays alive, but if the actor 
> is destroyed - the stream has to be shut down as well.
> When I construct part of the stream flow, that has to be responsible for 
> the logic above, I have only an ActorRef of the master actor I want bind 
> the stream life-cycle to.
>
> Originally I wanted to do the following: during stream materialization I 
> get its KillSwitch and create an aux actor with KillSwitch and master 
> ActorRef as parameters. The aux actor will create a watch for the master 
> actor and kill the stream using KillSwitch, once master actor shuts down.
>
> As an alternative I can probably create a branch in the flow, filter off 
> all the possible events/messages and attach the master actor as a 
> Sink.actorRef.
>
> WDYT?
>
> Thanks.
>
> WBR,
> Alexey
>
> On Sat, Jul 30, 2016 at 1:41 PM, Konrad Malawski  > wrote:
>
>> Not using safe APIs.
>> But instead I'd turn around the question and ask what you're trying to 
>> achieve?
>> Perhaps there's a cleaner way than reaching out to the ActorSystem.
>>
>> -- 
>> Konrad `ktoso` Malawski
>> Akka  @ Lightbend 
>>
>> On 30 July 2016 at 22:39:47, oleksiys (kvr...@gmail.com ) 
>> wrote:
>>
>> Hi,
>>
>> is it possible to get access to the ActorSystem, that is being used to 
>> materialize the stream during materialization?
>>
>> Something like:
>>
>> Flow[String].viaMat(*ExposeActorSystemMat.instance*).mapMaterializedValue(actorSystem
>>  
>> => doSomethingWithActorSystem(actorSystem))
>>
>> Thanks.
>>
>> WBR,
>> Alexey
>> --
>> >> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>

-- 
>>  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.


Re: [akka-user] Get ActorSystem as part of a stream materialization process

2016-07-30 Thread Konrad Malawski
(feel free to copy paste the entire impl and use as-is if you want to btw)

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 31 July 2016 at 00:52:56, Konrad Malawski (konrad.malaw...@lightbend.com)
wrote:

I like the idea, this can indeed be very useful!
We'll see what the rest of the team has to say about it.

I took a shot at implementing it actually, so here it is:
https://github.com/akka/akka/pull/21076

No guarantees about bug-free ness, but it seems rather complete ;-)


It also shows of how awesome GraphStage really is, esp. with it's
StageActor feature which we'll blog about more in the near future.
Just yesterday we published a post introducing GraphStage a bit from a
birds view btw:
http://blog.akka.io/streams/2016/07/30/mastering-graph-stage-part-1
Track the blog if you want to learn interesting stuff about internals like
that :-)


Happy hakking!

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 30 July 2016 at 23:19:17, Alexey S (kvr...@gmail.com) wrote:

I'm trying to bind stream life-cycle to an actor life-cycle (let's call it
master actor). In a sense that if the stream is destroyed - the master
actor receives some Termination message but stays alive, but if the actor
is destroyed - the stream has to be shut down as well.
When I construct part of the stream flow, that has to be responsible for
the logic above, I have only an ActorRef of the master actor I want bind
the stream life-cycle to.

Originally I wanted to do the following: during stream materialization I
get its KillSwitch and create an aux actor with KillSwitch and master
ActorRef as parameters. The aux actor will create a watch for the master
actor and kill the stream using KillSwitch, once master actor shuts down.

As an alternative I can probably create a branch in the flow, filter off
all the possible events/messages and attach the master actor as a
Sink.actorRef.

WDYT?

Thanks.

WBR,
Alexey

On Sat, Jul 30, 2016 at 1:41 PM, Konrad Malawski <
konrad.malaw...@lightbend.com> wrote:

> Not using safe APIs.
> But instead I'd turn around the question and ask what you're trying to
> achieve?
> Perhaps there's a cleaner way than reaching out to the ActorSystem.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 30 July 2016 at 22:39:47, oleksiys (kvr...@gmail.com) wrote:
>
> Hi,
>
> is it possible to get access to the ActorSystem, that is being used to
> materialize the stream during materialization?
>
> Something like:
>
> Flow[String].viaMat(*ExposeActorSystemMat.instance*).mapMaterializedValue(actorSystem
> => doSomethingWithActorSystem(actorSystem))
>
> Thanks.
>
> WBR,
> Alexey
> --
> >> 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.
>
>

-- 
>>  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.


Re: [akka-user] Get ActorSystem as part of a stream materialization process

2016-07-30 Thread Konrad Malawski
I like the idea, this can indeed be very useful!
We'll see what the rest of the team has to say about it.

I took a shot at implementing it actually, so here it is:
https://github.com/akka/akka/pull/21076

No guarantees about bug-free ness, but it seems rather complete ;-)


It also shows of how awesome GraphStage really is, esp. with it's
StageActor feature which we'll blog about more in the near future.
Just yesterday we published a post introducing GraphStage a bit from a
birds view btw:
http://blog.akka.io/streams/2016/07/30/mastering-graph-stage-part-1
Track the blog if you want to learn interesting stuff about internals like
that :-)


Happy hakking!

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 30 July 2016 at 23:19:17, Alexey S (kvr...@gmail.com) wrote:

I'm trying to bind stream life-cycle to an actor life-cycle (let's call it
master actor). In a sense that if the stream is destroyed - the master
actor receives some Termination message but stays alive, but if the actor
is destroyed - the stream has to be shut down as well.
When I construct part of the stream flow, that has to be responsible for
the logic above, I have only an ActorRef of the master actor I want bind
the stream life-cycle to.

Originally I wanted to do the following: during stream materialization I
get its KillSwitch and create an aux actor with KillSwitch and master
ActorRef as parameters. The aux actor will create a watch for the master
actor and kill the stream using KillSwitch, once master actor shuts down.

As an alternative I can probably create a branch in the flow, filter off
all the possible events/messages and attach the master actor as a
Sink.actorRef.

WDYT?

Thanks.

WBR,
Alexey

On Sat, Jul 30, 2016 at 1:41 PM, Konrad Malawski <
konrad.malaw...@lightbend.com> wrote:

> Not using safe APIs.
> But instead I'd turn around the question and ask what you're trying to
> achieve?
> Perhaps there's a cleaner way than reaching out to the ActorSystem.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 30 July 2016 at 22:39:47, oleksiys (kvr...@gmail.com) wrote:
>
> Hi,
>
> is it possible to get access to the ActorSystem, that is being used to
> materialize the stream during materialization?
>
> Something like:
>
> Flow[String].viaMat(*ExposeActorSystemMat.instance*).mapMaterializedValue(actorSystem
> => doSomethingWithActorSystem(actorSystem))
>
> Thanks.
>
> WBR,
> Alexey
> --
> >> 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.
>
>

-- 
>>  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.


Re: [akka-user] Get ActorSystem as part of a stream materialization process

2016-07-30 Thread Alexey S
I'm trying to bind stream life-cycle to an actor life-cycle (let's call it
master actor). In a sense that if the stream is destroyed - the master
actor receives some Termination message but stays alive, but if the actor
is destroyed - the stream has to be shut down as well.
When I construct part of the stream flow, that has to be responsible for
the logic above, I have only an ActorRef of the master actor I want bind
the stream life-cycle to.

Originally I wanted to do the following: during stream materialization I
get its KillSwitch and create an aux actor with KillSwitch and master
ActorRef as parameters. The aux actor will create a watch for the master
actor and kill the stream using KillSwitch, once master actor shuts down.

As an alternative I can probably create a branch in the flow, filter off
all the possible events/messages and attach the master actor as a
Sink.actorRef.

WDYT?

Thanks.

WBR,
Alexey

On Sat, Jul 30, 2016 at 1:41 PM, Konrad Malawski <
konrad.malaw...@lightbend.com> wrote:

> Not using safe APIs.
> But instead I'd turn around the question and ask what you're trying to
> achieve?
> Perhaps there's a cleaner way than reaching out to the ActorSystem.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 30 July 2016 at 22:39:47, oleksiys (kvr...@gmail.com) wrote:
>
> Hi,
>
> is it possible to get access to the ActorSystem, that is being used to
> materialize the stream during materialization?
>
> Something like:
>
> Flow[String].viaMat(*ExposeActorSystemMat.instance*).mapMaterializedValue(actorSystem
> => doSomethingWithActorSystem(actorSystem))
>
> Thanks.
>
> WBR,
> Alexey
> --
> >> 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.
>
>

-- 
>>  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.


Re: [akka-user] Get ActorSystem as part of a stream materialization process

2016-07-30 Thread Konrad Malawski
Not using safe APIs.
But instead I'd turn around the question and ask what you're trying to
achieve?
Perhaps there's a cleaner way than reaching out to the ActorSystem.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 30 July 2016 at 22:39:47, oleksiys (kvr...@gmail.com) wrote:

Hi,

is it possible to get access to the ActorSystem, that is being used to
materialize the stream during materialization?

Something like:

Flow[String].viaMat(*ExposeActorSystemMat.instance*).mapMaterializedValue(actorSystem
=> doSomethingWithActorSystem(actorSystem))

Thanks.

WBR,
Alexey
--
>> 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.

-- 
>>  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.