diff --git a/.github/workflows/hex.yml b/.github/workflows/hex.yml index 5565375..7cd39a2 100644 --- a/.github/workflows/hex.yml +++ b/.github/workflows/hex.yml @@ -6,10 +6,26 @@ on: jobs: publish: runs-on: ubuntu-latest + name: Publish + strategy: + matrix: + otp: ['26'] + elixir: ['1.15.7'] + env: + HEX_API_KEY: ${{ secrets.HEX_API_KEY }} steps: - - name: Check out - uses: actions/checkout@v4 - - name: Publish to Hex.pm - uses: wesleimp/action-publish-hex@v1 - env: - HEX_API_KEY: ${{ secrets.HEX_API_KEY }} + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{matrix.otp}} + elixir-version: ${{matrix.elixir}} + - name: Restore dependencies cache + uses: actions/cache@v4 + with: + path: deps + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps-${{ hashFiles('**/mix.lock') }} + ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-release-deps + - run: mix deps.get + - run: mix hex.publish --yes diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a628d7..10155e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [3.1.0] (2024-08-14) + +### Enhancements +- Add `:enabled` config value +- `:adapter` config value is now optional and defaults to `Coney.RabbitConnection` + ## [3.0.2] (2024-08-12) ### Bug fixes diff --git a/README.md b/README.md index 1261144..fb0937a 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ Default config: ```elixir # config/config.exs config :coney, - adapter: Coney.RabbitConnection, auto_start: true, settings: %{ url: "amqp://guest:guest@localhost", # or ["amqp://guest:guest@localhost", "amqp://guest:guest@other_host"] @@ -77,7 +76,6 @@ Also, you can create a confuguration module (if you want to retreive settings fr ```elixir # config/config.exs config :coney, - adapter: Coney.RabbitConnection, auto_start: true, settings: RabbitConfig, topology: RabbitConfig @@ -133,6 +131,12 @@ defmodule YourApplication do end ``` +If you want to disable Coney altogether (useful for testing config) set `enabled: false` +```elixir +# config/config.exs +config :coney, enabled: false, settings: %{}, topology: %{} +``` + ## Configure consumers ```elixir diff --git a/config/config.exs b/config/config.exs index 83f7fa2..4da1c06 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,7 +1,6 @@ import Config config :coney, - adapter: Coney.RabbitConnection, pool_size: 1, auto_start: true, settings: %{ diff --git a/config/test.exs b/config/test.exs index 7dacb07..f7a9b22 100644 --- a/config/test.exs +++ b/config/test.exs @@ -14,7 +14,6 @@ config :coney, } } }, - adapter: Coney.RabbitConnection, pool_size: 1, auto_start: true, settings: %{ diff --git a/lib/coney/application_supervisor.ex b/lib/coney/application_supervisor.ex index 88894d3..60fb18e 100644 --- a/lib/coney/application_supervisor.ex +++ b/lib/coney/application_supervisor.ex @@ -24,17 +24,25 @@ defmodule Coney.ApplicationSupervisor do def init([consumers]) do settings = settings() - children = [ - {ConnectionServer, [settings]}, - {ConsumerSupervisor, [consumers]} - ] + {enabled?, settings} = Keyword.pop!(settings, :enabled) + + children = + if enabled? do + [ + {ConnectionServer, [settings]}, + {ConsumerSupervisor, [consumers]} + ] + else + [] + end Supervisor.init(children, strategy: :one_for_one) end def settings do [ - adapter: Application.get_env(:coney, :adapter), + adapter: Application.get_env(:coney, :adapter, Coney.RabbitConnection), + enabled: Application.get_env(:coney, :enabled, true), settings: get_config(:settings, :settings), topology: get_config(:topology, :topology, %{exchanges: [], queues: []}) ] diff --git a/mix.exs b/mix.exs index 6860178..d5dccf3 100644 --- a/mix.exs +++ b/mix.exs @@ -4,8 +4,8 @@ defmodule Coney.Mixfile do def project do [ app: :coney, - version: "3.0.2", - elixir: ">= 1.10.0", + version: "3.1.0", + elixir: ">= 1.12.0", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, description: description(),