Implements a functional version of the Chain of Responsibility pattern.
Implements a functional version of the Chain of Responsibility pattern. The Chain of Responsibility pattern is a GoF design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain.
In this Scala version, processing steps are defined as functions, which the Chain links together via either the chainWith() or +> operations. The return value is defined as an Either[A, B]: - Left[A] to direct processing by the next handler - Right[B] to direct that processing must stop with the preceeding result.
The ThreadLocal gets initialized by the init that is passed in when needed.
The ThreadLocal gets initialized by the init that is passed in when needed. And, because it just extends java.lang.ThreadLocal, you can also call set on it too.
Usage: val tl = new ThreadLocal(System.currentTimeMillis)
// these three are all equivalent, and depends on your taste tl.withValue { v => System.out.println(v) } System.out.println(tl.get) System.out.println(tl())
Extractor of non-fatal Throwables.
Extractor of non-fatal Throwables. Will not match fatal errors like VirtualMachineError (OutOfMemoryError) ThreadDeath, LinkageError and InterruptedException. StackOverflowError is matched, i.e. considered non-fatal.
Usage to catch all harmless throwables:
try { // dangerous stuff } catch { case NonFatal(e) => log.error(e, "Something not that bad") }
makes an emptyBehavior PartialFunction expression that matches no messages at all, ever.
Transforms a function into one that accepts Future arguments and outputs Future results.
Transforms a function into one that accepts Future arguments and outputs Future results. Used in function composition that pertains to concurrent operations. TODO: MOVE INTO PEDS.