Discussion:
[akka-user][deprecated] Stream loops
Beno
2018-09-30 03:14:53 UTC
Permalink
Hello,

I have seen threads on this forum where Akka team recommends trying to
avoid stream loops ("they are tricky"). I have a use case where steams with
loops could be a solution to otherwise difficult problem.

the payload of the stream is a list of automatically formed case classes
from an input file, plus a wrapper case class with . at a given stage:

1. pop the next case class in the list and match {
case A --> do some stuff, pull some info out of A, set a field (i.e.
create new case object to preserve immutabilty) of the wrapper case class =
to a field of the A class, loop back to this stage with the list of case
classes not including A
case B --> do other stuff, add info from B to wrapper case class, loop
back to this stage with list of case classes not including B
.
.
.
} . // and the point here is there could be 0 to many As, Bs, Cs, etc
case F --> send to AthroughEExhaustedState

2. AthroughEExhaustedState might have its own similar rules

is this insanity? or am I missing a much better solution?
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon.
** This group will soon be put into read-only mode, and replaced by discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
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.
Brian Maso
2018-10-01 01:03:21 UTC
Permalink
I've used loops before in Akka Streams. They are tricky, and debugging is
hard, but sometimes is the right fit. I think there is an analog to
recursion, though. Many things that can be expressed as a recursive loop
can also be expressed as an unfold, and that might be a better way of doing
it.

Brian Maso
Post by Beno
Hello,
I have seen threads on this forum where Akka team recommends trying to
avoid stream loops ("they are tricky"). I have a use case where steams with
loops could be a solution to otherwise difficult problem.
the payload of the stream is a list of automatically formed case classes
1. pop the next case class in the list and match {
case A --> do some stuff, pull some info out of A, set a field (i.e.
create new case object to preserve immutabilty) of the wrapper case class =
to a field of the A class, loop back to this stage with the list of case
classes not including A
case B --> do other stuff, add info from B to wrapper case class,
loop back to this stage with list of case classes not including B
.
.
.
} . // and the point here is there could be 0 to many As, Bs, Cs, etc
case F --> send to AthroughEExhaustedState
2. AthroughEExhaustedState might have its own similar rules
is this insanity? or am I missing a much better solution?
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon.
** This group will soon be put into read-only mode, and replaced by discuss.akka.io
https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
Read the docs: http://akka.io/docs/
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
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon.
** This group will soon be put into read-only mode, and replaced by discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
Post by Beno
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.
Loading...