Implementing the Pipes and Filters Pattern Using Actors in Akka for Java
iteratrlearning.com
iteratrlearning.com
http://eed3si9n.com/learning-scalaz/Either.html
text >>= (t => if (containsForbiddenWord) { MyError.left[String] } else { t.right[MyError] })
>>= latexToUnicode _
>>= ...etc...
Unlike actors, this is deterministic and easily testable code.If you really need to use a fancy concurrent system for this, Akka already has a built in piping/filtering framework called streams:
http://doc.akka.io/docs/akka/2.4.16/scala/stream/index.html
Unlike this actor example, streams comes with built in backpressure/concurrency handling.
For new code you should probably be using streams rather than akka actors.
This article is neat for learning about actors, but you should almost certainly not write production code this way.
But I'm sure Java has some similar deterministic abstraction. I know Java used to just use deterministic functions + exceptions, and that was hardly unreasonable.
That said, the code I see seems very verbose, particularly the config part, for what amounts to:
text-checker | latex2unicode | upload-to-s3
In my own Objective-C based P/F implementation, I currently deal with pipes as arrays of filters, so it would be something like: [MPWPipe pipeWithFilters:@[ textChecker, latex2unicode, upload-to-s3 ]];
In Objective-Smalltalk, I'd think I can do better.Not everything has to be done for the sole purpose of being the best solution.