diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 095dcc5..294b855 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ jobs: MIX_ENV: test EVENTSTORE_HOST: localhost EVENTSTORE_VERSION: nightly - steps: - name: Checkout uses: actions/checkout@v3 @@ -20,35 +19,28 @@ jobs: - name: Spawn docker-compose EventStoreDB container run: docker-compose up --detach eventstore - - name: Determine the elixir version - run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV - - - name: Determine the otp version - run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV - - name: Setup Elixir and Erlang versions uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache uses: actions/cache@v3 id: deps-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps path: deps - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps- - name: Restore the _build cache uses: actions/cache@v3 id: build-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build path: _build - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build- - name: Fetch mix dependencies if: steps.deps-cache.outputs.cache-hit != 'true' @@ -75,6 +67,29 @@ jobs: - name: Credo run: mix credo + - name: Restore PLT cache + uses: actions/cache/restore@v3 + id: plt-cache + with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + path: priv/plts + + - name: Create PLTs + shell: sh + if: steps.plt-cache.outputs.cache-hit != 'true' + run: mix dialyzer --plt + + - name: Save PLT cache + uses: actions/cache/save@v3 + if: steps.plt-cache.outputs.cache-hit != 'true' + with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt + path: priv/plts + + - name: Run dialyzer + run: mix dialyzer --format github + publish-hex-package: name: Publish Hex Package ⬆️☁️ runs-on: ubuntu-20.04 @@ -88,35 +103,28 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Determine the elixir version - run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV - - - name: Determine the otp version - run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV - - name: Setup Elixir and Erlang versions uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache uses: actions/cache@v3 id: deps-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps path: deps - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps- - name: Restore the _build cache uses: actions/cache@v3 id: build-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build path: _build - key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build- - name: Fetch mix dependencies if: steps.deps-cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 785cda2..bd83323 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -9,11 +9,6 @@ jobs: strategy: fail-fast: false matrix: - beam: - - elixir: "1.7.4" - otp: "21.3" - - elixir: "1.12.3" - otp: "24.0" eventstore: - 20.10.2 - 22.6.0 @@ -21,10 +16,9 @@ jobs: MIX_ENV: test EVENTSTORE_HOST: localhost EVENTSTORE_VERSION: ${{ matrix.eventstore }} - steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set the EventStoreDB version run: sed -i 's|ghcr.io/eventstore/eventstore:ci|eventstore/eventstore:${{ matrix.eventstore }}-buster-slim|g' docker-compose.yml @@ -34,27 +28,26 @@ jobs: - name: Setup Elixir and Erlang versions uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ matrix.beam.otp }} - elixir-version: ${{ matrix.beam.elixir }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache - uses: actions/cache@v1 + uses: actions/cache@v3 id: deps-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-deps path: deps - key: ${{ runner.os }}-${{ matrix.beam.elixir }}-${{ matrix.beam.otp }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ matrix.beam.elixir }}-${{ matrix.beam.otp }}-${{ env.MIX_ENV }}-deps- - name: Restore the _build cache - uses: actions/cache@v1 + uses: actions/cache@v3 id: build-cache with: + key: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build + restore-keys: ${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-${{ env.MIX_ENV }}-build path: _build - key: ${{ runner.os }}-${{ matrix.beam.elixir }}-${{ matrix.beam.otp }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} - restore-keys: | - ${{ runner.os }}-${{ matrix.beam.elixir }}-${{ matrix.beam.otp }}-${{ env.MIX_ENV }}-build- - name: Fetch mix dependencies if: steps.deps-cache.outputs.cache-hit != 'true' @@ -72,6 +65,3 @@ jobs: - name: Run tests run: mix test --exclude version_incompatible - - - name: Credo - run: mix credo diff --git a/.github/workflows/refresh-dev-cache.yml b/.github/workflows/refresh-dev-cache.yml index 06fafeb..de30c11 100644 --- a/.github/workflows/refresh-dev-cache.yml +++ b/.github/workflows/refresh-dev-cache.yml @@ -37,19 +37,14 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 - - - name: Determine the elixir version - run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV - - - name: Determine the otp version - run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV + uses: actions/checkout@v3 - name: Setup Elixir and Erlang versions - uses: erlef/setup-beam@v1.7.0 + uses: erlef/setup-beam@v1 + id: beam with: - otp-version: ${{ env.OTP_VERSION }} - elixir-version: ${{ env.ELIXIR_VERSION }} + version-file: .tool-versions + version-type: strict - name: Restore the deps cache uses: actions/cache@v1 diff --git a/.gitignore b/.gitignore index e89b9eb..00a75bf 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ erl_crash.dump # Ignore package tarball (built via "mix hex.build"). spear-*.tar - # Temporary files for e.g. tests /tmp + +/priv/plts/*.plt +/priv/plts/*.plt.hash diff --git a/.tool-versions b/.tool-versions index 93a429b..f08de31 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.12.3-otp-24 -erlang 24.0 +elixir 1.14.5-otp-26 +erlang 26.0 diff --git a/config/config.exs b/config/config.exs index 8233fe9..983b681 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,3 +1,13 @@ -use Mix.Config +import Config -import_config "#{Mix.env()}.exs" +config :spear, Spear.Test.ClientFixture, connection_string: "esdb://localhost:2113" + +host = System.get_env("EVENTSTORE_HOST") || "localhost" + +config :spear, :config, + connection_string: "esdb://admin:changeit@#{host}:2113?tls=true", + mint_opts: [ + transport_opts: [ + cacertfile: Path.join([__DIR__ | ~w(.. eventstoredb certs ca ca.crt)]) + ] + ] diff --git a/config/dev.exs b/config/dev.exs deleted file mode 100644 index d2d855e..0000000 --- a/config/dev.exs +++ /dev/null @@ -1 +0,0 @@ -use Mix.Config diff --git a/config/prod.exs b/config/prod.exs deleted file mode 100644 index d2d855e..0000000 --- a/config/prod.exs +++ /dev/null @@ -1 +0,0 @@ -use Mix.Config diff --git a/config/test.exs b/config/test.exs deleted file mode 100644 index 0000cfb..0000000 --- a/config/test.exs +++ /dev/null @@ -1,13 +0,0 @@ -use Mix.Config - -config :spear, Spear.Test.ClientFixture, connection_string: "esdb://localhost:2113" - -host = System.get_env("EVENTSTORE_HOST") || "localhost" - -config :spear, :config, - connection_string: "esdb://admin:changeit@#{host}:2113?tls=true", - mint_opts: [ - transport_opts: [ - cacertfile: Path.join([__DIR__ | ~w(.. eventstoredb certs ca ca.crt)]) - ] - ] diff --git a/docker-compose.yml b/docker-compose.yml index ce77b54..bda3fb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: # messages via wireshark # command: "--insecure --run-projections=All" ports: - - 2113:2113 + - '2113:2113' app: image: elixir:1.12.2 diff --git a/lib/spear.ex b/lib/spear.ex index 34a21fa..faaa60b 100644 --- a/lib/spear.ex +++ b/lib/spear.ex @@ -1993,7 +1993,7 @@ defmodule Spear do stream_name :: String.t() | :all, group_name :: String.t(), opts :: Keyword.t() - ) :: {:ok, Spear.PersistentSubcription.Info.t()} | {:error, any()} + ) :: {:ok, Spear.PersistentSubscription.Info.t()} | {:error, any()} def get_persistent_subscription_info(conn, stream_name, group_name, opts \\ []) when (is_binary(stream_name) or stream_name == :all) and is_binary(group_name) do get_info_message = diff --git a/lib/spear/connection.ex b/lib/spear/connection.ex index 03d6efc..707cb2b 100644 --- a/lib/spear/connection.ex +++ b/lib/spear/connection.ex @@ -88,6 +88,8 @@ defmodule Spear.Connection do defstruct [:config, :conn, requests: %{}, keep_alive_timer: %KeepAliveTimer{}] + @type state :: %__MODULE__{} + @typedoc """ A connection process @@ -152,9 +154,7 @@ defmodule Spear.Connection do %Config{errors: errors} -> error_lines = - errors - |> Enum.map(fn {key, error} -> "\t#{inspect(key)}: #{error}" end) - |> Enum.join("\n") + Enum.map_join(errors, "\n", fn {key, error} -> "\t#{inspect(key)}: #{error}" end) Logger.error(""" Invalid configuration passed to #{inspect(__MODULE__)}. Found the following errors: @@ -327,10 +327,10 @@ defmodule Spear.Connection do def handle_info(:keep_alive_expired, s), do: {:disconnect, :keep_alive_timeout, s} def handle_info(message, s) do - with %Mint.HTTP2{} = conn <- s.conn, - {:ok, conn, responses} <- Mint.HTTP2.stream(conn, message) do - {:noreply, put_in(s.conn, conn) |> handle_responses(responses)} - else + case Mint.HTTP2.stream(s.conn, message) do + {:ok, conn, responses} -> + {:noreply, put_in(s.conn, conn) |> handle_responses(responses)} + # coveralls-ignore-start {:error, conn, reason, responses} -> s = put_in(s.conn, conn) |> handle_responses(responses) diff --git a/lib/spear/connection/request.ex b/lib/spear/connection/request.ex index e2a3622..024aa5f 100644 --- a/lib/spear/connection/request.ex +++ b/lib/spear/connection/request.ex @@ -77,8 +77,8 @@ defmodule Spear.Connection.Request do {[{message, message_size} | message_buffer], message_size + message_buffer_size, max_size}} end - @spec emit_messages(%Spear.Connection{}, %__MODULE__{}) :: - {:ok, %Spear.Connection{}} | {:error, %Spear.Connection{}, reason :: any()} + @spec emit_messages(Spear.Connection.state(), %__MODULE__{}) :: + {:ok, Spear.Connection.state()} | {:error, Spear.Connection.state(), reason :: any()} def emit_messages(state, %__MODULE__{status: :done, buffer: <<>>}), do: {:ok, state} def emit_messages(state, %__MODULE__{status: :done, buffer: buffer} = request) do diff --git a/lib/spear/connection/response.ex b/lib/spear/connection/response.ex index 2aa4ba1..9b14880 100644 --- a/lib/spear/connection/response.ex +++ b/lib/spear/connection/response.ex @@ -3,5 +3,12 @@ defmodule Spear.Connection.Response do # a slim data structure for storing information about an HTTP/2 response + @type t :: %__MODULE__{ + status: Mint.Types.status(), + type: {module(), atom()}, + headers: Mint.Types.headers(), + data: binary() + } + defstruct [:status, :type, headers: [], data: <<>>] end diff --git a/lib/spear/reading/stream.ex b/lib/spear/reading/stream.ex index 3bd4eb2..ce9e32a 100644 --- a/lib/spear/reading/stream.ex +++ b/lib/spear/reading/stream.ex @@ -82,7 +82,7 @@ defmodule Spear.Reading.Stream do response end - @spec unfold_chunk(binary()) :: {struct(), binary()} | nil + @spec unfold_chunk(binary()) :: {tuple(), binary()} | nil def unfold_chunk(buffer) when is_binary(buffer) do Spear.Grpc.decode_next_message( buffer, diff --git a/mix.exs b/mix.exs index 5c37f2c..872bd51 100644 --- a/mix.exs +++ b/mix.exs @@ -25,14 +25,18 @@ defmodule Spear.MixProject do inch: :dev, bless: :test, test: :test, - dialyzer: :test + dialyzer: :dev ], name: "Spear", source_url: @source_url, deps: deps(), docs: docs(), package: package(), - description: description() + description: description(), + dialyzer: [ + plt_add_apps: [:jason], + plt_file: {:no_warn, "priv/plts/dialyzer.plt"} + ] ] end @@ -50,14 +54,16 @@ defmodule Spear.MixProject do {:event_store_db_gpb_protobufs, "~> 2.2"}, {:connection, "~> 1.0"}, # optional dependencies - {:jason, ">= 0.0.0", optional: true}, + {:jason, "~> 1.0", optional: true}, + # dev/test utilities {:castore, ">= 0.0.0", only: [:dev, :test]}, - {:ex_doc, "~> 0.24", only: :dev, runtime: false}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, + {:dialyxir, ">= 0.0.0", only: [:dev, :test], runtime: false}, # testing suite - {:credo, "~> 1.5", only: :test}, + {:credo, ">= 0.0.0", only: :test}, {:bless, "~> 1.0", only: :test}, - {:excoveralls, "~> 0.7", only: :test} + {:excoveralls, ">= 0.0.0", only: :test} ] end diff --git a/mix.lock b/mix.lock index 99a4246..7db756a 100644 --- a/mix.lock +++ b/mix.lock @@ -1,26 +1,28 @@ %{ "bless": {:hex, :bless, "1.1.0", "b27571e49a4ba22d92412184740b186448a27c3ddf2e9e687851e937932b5a60", [:mix], [], "hexpm", "ea5dc19a36609f927d4035a8409393cd3016b5c482245cffa30b3bd6669c617e"}, - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "castore": {:hex, :castore, "0.1.10", "b01a007416a0ae4188e70b3b306236021b16c11474038ead7aff79dd75538c23", [:mix], [], "hexpm", "a48314e0cb45682db2ea27b8ebfa11bd6fa0a6e21a65e5772ad83ca136ff2665"}, - "certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"}, + "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, + "castore": {:hex, :castore, "0.1.22", "4127549e411bedd012ca3a308dede574f43819fe9394254ca55ab4895abfa1a2", [:mix], [], "hexpm", "c17576df47eb5aa1ee40cc4134316a99f5cad3e215d5c77b8dd3cfef12a22cac"}, + "certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"}, "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, - "credo": {:hex, :credo, "1.5.6", "e04cc0fdc236fefbb578e0c04bd01a471081616e741d386909e527ac146016c6", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4b52a3e558bd64e30de62a648518a5ea2b6e3e5d2b164ef5296244753fc7eb17"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.29", "149d50dcb3a93d9f3d6f3ecf18c918fb5a2d3c001b5d3305c926cddfbd33355b", [:mix], [], "hexpm", "4902af1b3eb139016aed210888748db8070b8125c2342ce3dcae4f38dcc63503"}, + "credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"}, + "dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"}, + "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "event_store_db_gpb_protobufs": {:hex, :event_store_db_gpb_protobufs, "2.2.0", "fca2bdeac5fca205e02d3cb9f170477a5422e147413d21d07c19e1ffc70e66aa", [:rebar3], [{:gpb, "~> 4.0", [hex: :gpb, repo: "hexpm", optional: false]}], "hexpm", "dad49149eb6913805277a698ec1f607aac945c40cbf427aa03cc97309fdf2f1f"}, - "ex_doc": {:hex, :ex_doc, "0.29.0", "4a1cb903ce746aceef9c1f9ae8a6c12b742a5461e6959b9d3b24d813ffbea146", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "f096adb8bbca677d35d278223361c7792d496b3fc0d0224c9d4bc2f651af5db1"}, - "excoveralls": {:hex, :excoveralls, "0.14.1", "14140e4ef343f2af2de33d35268c77bc7983d7824cb945e6c2af54235bc2e61f", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4a588f9f8cf9dc140cc1f3d0ea4d849b2f76d5d8bee66b73c304bb3d3689c8b0"}, + "ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"}, + "excoveralls": {:hex, :excoveralls, "0.16.1", "0bd42ed05c7d2f4d180331a20113ec537be509da31fed5c8f7047ce59ee5a7c5", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "dae763468e2008cf7075a64cb1249c97cb4bc71e236c5c2b5e5cdf1cfa2bf138"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "gpb": {:hex, :gpb, "4.19.5", "ff9d434308fd205c07b662a86c37e9579a8c9a04ad511d2c4dd63430a59f4729", [:make, :rebar3], [], "hexpm", "21b76750d66b459ce40cb14298fb38ef8e0161d9b672a5284585c02563806f8e"}, - "hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"}, + "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~> 2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, - "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"}, "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mint": {:hex, :mint, "1.3.0", "396b3301102f7b775e103da5a20494b25753aed818d6d6f0ad222a3a018c3600", [:mix], [{:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "a9aac960562e43ca69a77e5176576abfa78b8398cec5543dd4fb4ab0131d5c1e"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, diff --git a/priv/plts/.gitignore b/priv/plts/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/priv/plts/.gitignore @@ -0,0 +1 @@ +* diff --git a/test/spear/connection_test.exs b/test/spear/connection_test.exs index 018cd88..d02fe63 100644 --- a/test/spear/connection_test.exs +++ b/test/spear/connection_test.exs @@ -3,7 +3,11 @@ defmodule Spear.ConnectionTest do import ExUnit.CaptureLog - @good_config Application.fetch_env!(:spear, :config) + @good_config Application.compile_env!(:spear, :config) + + defmodule MfaTest do + def send_me(pid), do: send(pid, :mfa_invoked) + end describe "given a connection_string leading nowhere" do setup do @@ -77,14 +81,8 @@ defmodule Spear.ConnectionTest do end test "a connection started with a :on_connect MFA invokes it at each connection" do - defmodule MfaTest do - def send_me(pid), do: send(pid, :mfa_invoked) - end - my_pid = self() - config = [{:on_connect, {MfaTest, :send_me, [my_pid]}} | @good_config] - conn = start_supervised!({Spear.Connection, config}) assert_receive(:mfa_invoked) @@ -94,14 +92,8 @@ defmodule Spear.ConnectionTest do end test "a connection started with a :on_disconnect MFA invokes it at each disconnection" do - defmodule MfaTest do - def send_me(pid), do: send(pid, :mfa_invoked) - end - my_pid = self() - config = [{:on_disconnect, {MfaTest, :send_me, [my_pid]}} | @good_config] - conn = start_supervised!({Spear.Connection, config}) assert Connection.call(conn, :close) == {:ok, :closed} diff --git a/test/spear_test.exs b/test/spear_test.exs index 9bd148c..a8b9523 100644 --- a/test/spear_test.exs +++ b/test/spear_test.exs @@ -10,7 +10,7 @@ defmodule SpearTest do @max_append_bytes 1_048_576 @checkpoint_after 32 * 32 * 32 - @config Application.fetch_env!(:spear, :config) + @config Application.compile_env!(:spear, :config) setup do conn = start_supervised!({Spear.Connection, @config})