# Ecto Isolator
Prevent non-atomic side effects while the current process is inside an Ecto
transaction.
## Install
```elixir
{:ecto_isolator, "~> 0.2.0", only: [:dev, :test], runtime: false}
```
## Configure
```elixir
config :ecto_isolator,
repos: [MyApp.Repo]
```
`EctoIsolator.check!/3` raises `EctoIsolator.Error` immediately when any
configured repo is in a transaction. Call it directly before a side effect so
the operation cannot proceed.
## Adapters
Req is the only built-in adapter:
```elixir
Req.new()
|> EctoIsolator.Adapters.Req.attach()
|> Req.get!(url: "https://example.com")
```
For other libraries, keep the package-specific wrapper or adapter in the
consuming application and call `EctoIsolator.check!/3` immediately before the
side effect:
```elixir
EctoIsolator.check!(:swoosh, :deliver, details: %{mailer: MyApp.Mailer})
MyApp.Mailer.deliver(email)
```
## Ignores
Ignore rules receive an `EctoIsolator.Offense`:
```elixir
config :ecto_isolator,
ignore: [
{:req, fn offense -> offense.details.url =~ "localhost" end}
]
```
## Development
Run the package checks with Mix:
```bash
mix check
```