<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Changelog](#changelog)
  - [v2.2.0](#v220)
    - [Enhancements](#enhancements)
    - [Bug Fixes](#bug-fixes)
  - [v2.1.0](#v210)
    - [Enhancements](#enhancements-1)
    - [Bug Fixes](#bug-fixes-1)
    - [Deprecations](#deprecations)
  - [v2.0.0](#v200)
    - [Enhancements](#enhancements-2)
    - [Bug Fixes](#bug-fixes-2)
    - [Incompatible Changes](#incompatible-changes)
  - [v1.3.2](#v132)
    - [Bug Fixes](#bug-fixes-3)
  - [v1.3.1](#v131)
    - [Bug Fixes](#bug-fixes-4)
  - [v1.3.0](#v130)
    - [Enhancements](#enhancements-3)
    - [Bug Fixes](#bug-fixes-5)
  - [v1.2.0](#v120)
    - [Enhancements](#enhancements-4)
    - [Bug Fixes](#bug-fixes-6)
  - [v1.1.0](#v110)
    - [Enhancements](#enhancements-5)
    - [Bug Fixes](#bug-fixes-7)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Changelog

## v2.2.0

### Enhancements
* [13](https://github.com/C-S-D/retort/pull/13) - [@KronicDeth](https://github.com/KronicDeth)
  * Allow a different `Retort.Client.Generic` pid for each transition that a `Retort.Client.StateMachine` can make.  If transition is not in `pid_by_transition`, the older, `pid` key is used as a fallback.  `pid_by_transition` is not required.  If it is not given, `pid` is always used, which mimics the older behavior.
  * `Retort.Client.StateMachine` has full test coverage.

### Bug Fixes
* [13](https://github.com/C-S-D/retort/pull/13) - Add `config :retort, :ecto_repos: []` to `config/dev.exs` to suppress warning in dev. - [@KronicDeth](https://github.com/KronicDeth)

## v2.1.0

### Enhancements
* [#12](https://github.com/C-S-D/retort/pull/12) - [@KronicDeth](https://github.com/KronicDeth)
  * Extract `Retort.Resources.timeout/2` to `Retort.Resources.Timeout.get_or_default(module, function)`.   `Retort.Resources.Timeout` also has functions for deleting and putting module-wide and function name specific timeouts, to make testing easier and less boiler plate needed in override examples.
    * `Retort.Resources.Timeout.delete(module)` will delete `timeout`s set by `Retort.Resources.Timeout.put(module, timeout)` OR `Retort.Resources.Timeout.put(module, function_name, timeout)`.
    * `Retort.Resources.Timeout.delete(module, timeout)` will delete `timeout` set by `Retort.Resources.Timeout.put(module, function_name, timeout)` OR remove the `timeout` for `function_name` and leave it for the other function names when `Retort.Resources.Timeout.put(module, timeout)` is called.
    * `Retort.Resources.Timeout.put(module, timeout)` will set the `timeout` for all `Retort.Client.Generic` calls by `module` that called `use Retort.Resources`.
    * `Retort.Resources.Timeout.put(module, function_name, timeout)` will set the `timeout` for all `Retort.Client.Generic` `function_name` calls by `module` that called `use Retort.Resources`.
    * `Retort.Resources.Timeout.put(module, function_name, timeout, func)` will only temporarily `Retort.Resources.Timeout.put/3`, but for the duration passed function only.  This can be used to test timeout handling.
  * Update to `credo` `0.7.4`.

### Bug Fixes
* [#12](https://github.com/C-S-D/retort/pull/12) - Fix formatting of timeout override example code. - [@KronicDeth](https://github.com/KronicDeth)

### Deprecations
* [#12](https://github.com/C-S-D/retort/pull/12) - `Retort.Resources.timeout(module, function_name)` is deprecated; use `Retort.Resources.Timeout.get_or_default(module, function_name)` instead. - [@KronicDeth](https://github.com/KronicDeth)

## v2.0.0

### Enhancements
* [#9](https://github.com/C-S-D/retort/pull/9) - Document `Retort.Resources`. - [@KronicDeth](https://github.com/KronicDeth)
* [#10](https://github.com/C-S-D/retort/pull/10) - [@KronicDeth](https://github.com/KronicDeth)
  * Update to `alembic` `3.3.0`
    * Drop the need for `changeset_render` by using `JaSerializer.Formatter.Utils.format_key` directly to make it the same as `calcinator`.
  * Update to `calcinator` `3.0.0`
      * `Retort.Response.Error.to_calcinator_error(Retort.Response.t, Ecto.Changeset.t)` will convert `Retort.Response.t` `data` `Alembic.Document.t` `errors` to a `Calcinator` error.  If the `Alembic.Error.t` format is unrecognized, it is assumed to be convertable to `Ecto.Changeset.t` errors using `Retort.Response.Error.Ecto.Changeset.add_alembic_errors(changeset, errors)`
  * Error message instead of missing clause for unknown Poison version during tests.
  * Update dependencies
    * `amqp` `0.2.2`
    * `faker` `0.8.0`
    * `timex` `3.1.15`
* [#11](https://github.com/C-S-D/retort/pull/11) - [@KronicDeth](https://github.com/KronicDeth)
  * Update CircleCI
    * Erlang `19.3`
    * Elixir `1.4.2`

### Bug Fixes
* [#9](https://github.com/C-S-D/retort/pull/9) - [@KronicDeth](https://github.com/KronicDeth)
  * A missed rename left the application name used for `Application.get_env` as the original `:interpreter_server_rpc` instead of `:retort` in `Retort.Resources.timeout/2`.
  * Fix (`Map` -> `map`) typo  in `Retort.Client.Generic.start_link` options.
  * `Retort.Resources.client_start_link` should not have been 0-arity, but 1-arity, so it can take in the `client_start_link_options` as an argument instead of depending on lookup by `module` to retrieve some hidden state.
* [#10](https://github.com/C-S-D/retort/pull/10) - [@KronicDeth](https://github.com/KronicDeth)
  * `Retort.Meta.valid!/2` checked if the Ecto.Repo was sandboxed with `Application.get_env(:retort, Retort.Repo)`, which is a faithful translation of the original in `:interpreter_server_rpc`, but has the
  problem that it only works in `retort` itself.  To allow the repo to be check to be configured, `Retort.Meta.valid!/2` now takes an `:ecto_repo_module` option, which is check if its sandboxed if any of the `:ecto_schema_modules` are database-backed (have a non-blank `__schema__(:source)`).
  * `Retort.Server.Generic.Resources.handle_method/2` converts `{:error, :sandbox_token_missing}`  into RPC response errors instead of a `CaseClauseError` exception.
  * Use `alias Retort.Request` in `Retort.RequestTest`.
  * Increased allowed Cyclomatic Complexity for `credo` as it must be at least 10 (instead of default 9) for `Retort.Server.Generic.Resources.put_calcinator_error`.


### Incompatible Changes
* [#9](https://github.com/C-S-D/retort/pull/9) - `Retort.Resources.client_start_link` callback changes arity from `0` to `1` and now should take in `options` instead of calling `Retort.Resources.client_start_link_options/0`. - [@KronicDeth](https://github.com/KronicDeth)
* [#10](https://github.com/C-S-D/retort/pull/10) - [@KronicDeth](https://github.com/KronicDeth)
  * `Retort.Client.Generic.start_link` calls where the `ecto_schema_module_by_type` `ecto_schema_module`s are database-backed will now require `:ecto_repo_module` to check if the `Ecto.Repo.t` is sandboxed.
  * Require `alembic` `~> 3.3`
    * `changeset_render` is no longer needed for `Retort.Server.Generic.Resources`, so `Retort.Server.Generic.Resources.t` has been removed and a `Calcinator.t` should be used as the state instead.
  * Require to `calcinator` `~> 3.0`
    * `Retort.Response.Error.Ecto.Changeset.add_alembic_errors(changeset, [Alembic.Error.t])` will convert the `Alembic.Error.t`s to validation errors added to the `changeset`.  It's a way to reverse the conversion done by `Alembic.Document.from_ecto_changeset` in `alembic` `3.3.0`.
    * `Retort.Response.Error.to_calcinator_error(Retort.Response.t, Ecto.Changeset.t)` will convert `Retort.Response.t` `data` `Alembic.Document.t` `errors` to a `Calcinator` error.  If the `Alembic.Error.t` format is unrecognized, it is assumed to be convertable to `Ecto.Changeset.t` errors using `Retort.Response.Error.Ecto.Changeset.add_alembic_errors(changeset, errors)`
    * `Retort.Server.Generic.Resoruces.handle_method/2` is simplified using `put_rendered_or_error/2`, so that the large, duplicate `case`s are eliminated and error handling remains consistent across actions.  For error, `put_calcinator_error` is called.
    * `use Retort.Resources` generates `delete(changeset, query_options)` to match the updated `Calcinator.Resources.delete/2`.
    * `Retort.Resources.client_start_link_options` now takes `(module, query_options)`, so that if `:meta` exists in `query_options` and "beam" is set, then the pre-existing "beam" will be reused.
    * All action callbacks in `Retort.Resources` catch `{:exit, {:timeout, _}}` from the `Retort.Client.Generic` calls, log them, and then return `{:error, :timeout}`, so that `Calcinator.Controller` can turn it into a 504 Gateway Timeout instead of crashing the calling process.
    * All action callbacks in `Retort.Resources` can transform `{:error, %Retort.Response.Error{}}` to `Calcinator` errors using `Retort.Client.Generic.error_to_calcinator_error`.
    * `meta` in query_options is put back into the mergable params passed to `Retort.Client.Generic` calls in `Retort.Resources`
    * Coverage of all error returns from both `Calcinator.Resources.Ecto.Repo` and `Retort.Client.Generic` in tests.

## v1.3.2

### Bug Fixes
* [#7](https://github.com/C-S-D/retort/pull/7) - It was a bug that Calcinator allowed a list for filters instead of a map, so correct Retort to follow. - [@KronicDeth](https://github.com/KronicDeth)

## v1.3.1

### Bug Fixes
* [#6](https://github.com/C-S-D/retort/pull/6) - Restore poison 2.0 compatibility: `Retort.Request.from_string/1`'s return types only included the Poison 3.0 patterns, so `Retort.Server.Generic.RPC.decode_request/1` was only handling Poison 3.0 patterns.  Have `Retort.Request.from_string/1` return both Poison 2.0 and 3.0 patterns and have `Retort.Server.Generic.RPC.decode_request/1` handle both sets of patterns. - [@KronicDeth](https://github.com/KronicDeth)

## v1.3.0

### Enhancements
* [#5](https://github.com/C-S-D/retort/pull/5) - [@KronicDeth](https://github.com/KronicDeth)
  * Dependency updates
    * `alembic` to `3.2.0`
    * `calcinator` to `2.2.0`
    * `amqp` to `0.2.0` (Native support for Erlang 19!  No more need for the git dependency for Erlang 19 support.)
    * `ex_doc` `0.15.1`
    * `ex_machina` `2.0.0`
    * `ja_serializer` `0.12.0`
    * `junit_formatter` `1.3.0`
    * `timex` `3.1.13`
    * `uuid` `1.1.7`
    * `poison` `3.1.0`
    * `credo` `0.7.3`
  * Add CircleCI badge
  * Add HexFaktor badge
  * Add InchEx

### Bug Fixes
* [#5](https://github.com/C-S-D/retort/pull/5) - Fix Elixir 1.4 warnings - [@KronicDeth](https://github.com/KronicDeth)

## v1.2.0

### Enhancements
* [#3](https://github.com/C-S-D/retort/pull/3) -  Regression test for `use Retort.Resources` in dialyzer - [@KronicDeth](https://github.com/KronicDeth)

### Bug Fixes
* [#3](https://github.com/C-S-D/retort/pull/3) - [@KronicDeth](https://github.com/KronicDeth)
  * De-alias spec types in `Retort.Resources.__using__`  because spec types had no `alias` to setup correct alias names and `alias`es should not be used in `quote` block because they'll leak into module where `use` occurs.
  * Had to use `map` instead of `Alembic.Pagination.t` because `Alembic.Pagination.t` is not a subtype of `map` needed by `Calcinator.Resources.list` callback.
* [#4](https://github.com/C-S-D/retort/pull/4) - `|` has higher precedence than `->` so the `|` ends up being interpreted as `t -> {:ok, data}` OR `Retort.Client.Generic.error` instead of the correct `t ->` EITHER `{:ok, data}` OR `Retort.Client.Generic.error`. - [@KronicDeth](https://github.com/KronicDeth)

## v1.1.0

### Enhancements
* [#2](https://github.com/C-S-D/retort/pull/2) - [@KronicDeth](https://github.com/KronicDeth)
  * Ignore IntelliJ project files
  * Update to `calcinator` `2.1.0`
  * Update to `credo` `0.6.0`
  * Update to `timex` `3.1.8`
  * Update to `uuid` `1.1.6`

### Bug Fixes
* [#2](https://github.com/C-S-D/retort/pull/2) - [@KronicDeth](https://github.com/KronicDeth)
  * Fix `credo` `0.6.0` errors
    * Add missing `@spec`s
    * Remove extra blank lines
  * Fix Elixir 1.4 warnings about missing `()` on 0-arity function calls.
  * Use correct `rabbit_common` in `mix.lock` for Erlang 19+.
