cjmx/cjmx — pull request #6 by pchiusano (2013-11-05 15:54:50+00:00)
Title: Revised action type

Change is to representation of `Action`, which can now emit deltas to the `ActionContext` at any time while producing the output stream. I'm not sure this is really an improvement, but it's a point of comparison, and we can maybe talk about it.

```Scala
/**
* An action may read and write the formatter and connection state,
* but its status code is derived from whether it finishes
* successfully.
*/
type ActionResult = Writer[Task, ActionContext.Delta, Option[String]]
type Action = ActionContext => ActionResult
```

`ActionContext` is simplified somewhat:

```Scala
case class ActionContext(
connectionState: Option[JMXConnection] = None,
formatter: MessageFormatter = TextMessageFormatter,
lastStatusCode: Int = 0)
```

Actions can only issue 'deltas' to the `ActionContext`. This is needed so that actions cannot directly determine their status code, that is derived from whether they complete successfully or not:

```Scala
trait Delta extends (ActionContext => ActionContext)
case class Connect(c: JMXConnection) extends Delta
case object Disconnect extends Delta
case class Format(f: MessageFormatter) extends Delta
```

The REPL is written in a different style now, mostly driven by this change in representation.

If we want to accept this, I want to make sure the status code is being set properly with this new scheme. Are there any unit tests that exercise this already?