Applying the pipeline pattern

Author: Vassil Dichev
Date: 29.08.2016

Patterns

pattern (noun): a reliable sample of traits, acts, tendencies, or other observable characteristics

UNIX

We should have some ways of coupling programs like garden hose--screw in another segment when it becomes when it becomes necessary to massage data in another way.

M.D.McIlroy

October 11, 1964

Pipelines

Advantages

Characteristics

images/pipelining-lessons.jpg

UNIX pipe

Functional programming

"90% of functional programming is list processing"
  • map
images/map_pipeline.png
  • filter
images/filter_pipeline.png
  • reduce
images/reduce_pipeline.png

Loop with Java streams

employees.stream().
          filter(e -> e.getAge() > 30).
          map(Employee::getSalary).
          reduce(Integer::sum)

Java Streams

Java pipes

Reactive streams

asynchronous stream processing with non-blocking back pressure
Source(List(1,2,3)).
  filter(_ % 2 == 0).
  map(_ * 2).
  runFold(0)(_ + _).
  foreach(println)

Akka streams

images/actorz.png

Reactive pipeline

RxJava filter

images/filter.png

RxJava map

images/map.png

RxJava reduce

images/reduce.png

SentimentMetrics Library

SentimentMetrics, take 2

Sentiment pipeline

Sentiment services

images/sentiment.png

Conclusion

Stream-centric microservices

Services are composed using Unix-like pipelines (the Web meets Unix = true loose-coupling)

Juval Löwy