From 27b874c66db336049aafd886abc81c38cc074a78 Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:29:32 +0200 Subject: [PATCH 1/6] Updated dependencies --- mix.exs | 31 ++++++++++++++++++++----------- mix.lock | 38 +++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/mix.exs b/mix.exs index 35136d9..e658f2f 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule YggdrasilPostgres.MixProject do use Mix.Project - @version "5.0.2" + @version "6.0.0" @root "https://github.com/gmtprime/yggdrasil_postgres" def project do @@ -9,9 +9,10 @@ defmodule YggdrasilPostgres.MixProject do name: "Yggdrasil for PostgreSQL", app: :yggdrasil_postgres, version: @version, - elixir: "~> 1.8", + elixir: "~> 1.12", build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, + dialyzer: dialyzer(), package: package(), deps: deps(), docs: docs() @@ -30,12 +31,18 @@ defmodule YggdrasilPostgres.MixProject do defp deps do [ - {:yggdrasil, "~> 5.0"}, - {:skogsra, "~> 2.2"}, + {:yggdrasil, "~> 6.0"}, + {:skogsra, "~> 2.3"}, {:postgrex, "~> 0.15"}, - {:ex_doc, "~> 0.21", only: :dev, runtime: false}, - {:credo, "~> 1.2", only: :dev, runtime: false}, - {:dialyxir, "~> 1.0.0-rc.7", only: :dev, runtime: false} + {:ex_doc, "~> 0.24", only: [:dev, :test], runtime: false}, + {:credo, "~> 1.5", only: [:dev, :test], runtime: false}, + {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false} + ] + end + + def dialyzer do + [ + plt_file: {:no_warn, "priv/plts/yggdrasil_postgres.plt"} ] end @@ -60,12 +67,14 @@ defmodule YggdrasilPostgres.MixProject do defp docs do [ + main: "readme", source_url: @root, source_ref: "v#{@version}", - main: "readme", - formatters: ["html"], - groups_for_modules: groups_for_modules(), - extras: ["README.md"] + extras: [ + "README.md", + "CHANGELOG.md" + ], + groups_for_modules: groups_for_modules() ] end diff --git a/mix.lock b/mix.lock index 8091caf..96f2c08 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,26 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"}, - "credo": {:hex, :credo, "1.2.3", "fbd11a840e45dc42e650401e16acd2a39dde080240b974e146cc65e81ada1cd3", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "3c07d51ff43748bb959752ede70e40557cdcb7d61615e47ae1e9e108e0b1ceec"}, - "db_connection": {:hex, :db_connection, "2.2.1", "caee17725495f5129cb7faebde001dc4406796f12a62b8949f4ac69315080566", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "2b02ece62d9f983fcd40954e443b7d9e6589664380e5546b2b9b523cd0fb59e1"}, - "decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"}, - "dialyxir": {:hex, :dialyxir, "1.0.0-rc.7", "6287f8f2cb45df8584317a4be1075b8c9b8a69de8eeb82b4d9e6c761cf2664cd", [:mix], [{:erlex, ">= 0.2.5", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "506294d6c543e4e5282d4852aead19ace8a35bedeb043f9256a06a6336827122"}, + "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"}, + "db_connection": {:hex, :db_connection, "2.4.0", "d04b1b73795dae60cead94189f1b8a51cc9e1f911c234cc23074017c43c031e5", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad416c21ad9f61b3103d254a71b63696ecadb6a917b36f563921e0de00d7d7c8"}, + "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, + "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, - "erlex": {:hex, :erlex, "0.2.5", "e51132f2f472e13d606d808f0574508eeea2030d487fc002b46ad97e738b0510", [:mix], [], "hexpm", "756d3e19b056339af674b715fdd752c5dac468cf9d0e2d1a03abf4574e99fbf8"}, - "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, - "exreg": {:hex, :exreg, "0.1.0", "377c8cde927e299e3648b19bd7eaf09ec1e3ba02761b0fef5ad75c8df2fd29cf", [:mix], [], "hexpm", "3230b3bf7fa3a01dcf672b7c592e17626c6d5b2b693c8198ed9ce406ab2c827a"}, - "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, - "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm", "1f13f9f0f3e769a667a6b6828d29dec37497a082d195cc52dbef401a9b69bf38"}, - "poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"}, - "postgrex": {:hex, :postgrex, "0.15.3", "5806baa8a19a68c4d07c7a624ccdb9b57e89cbc573f1b98099e3741214746ae4", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4737ce62a31747b4c63c12b20c62307e51bb4fcd730ca0c32c280991e0606c90"}, - "skogsra": {:hex, :skogsra, "2.2.1", "93f328fafd07ef3931a2a87ae62ced80c37e85611eff21623923a0b4574dae6e", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:yamerl, "~> 0.7", [hex: :yamerl, repo: "hexpm", optional: true]}], "hexpm", "6b79f34346a6ae04d8218edc882abbf0c590159e9dc581af311b9b7fc5ee8ff2"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, + "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, + "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [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", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, + "exreg": {:hex, :exreg, "1.0.0", "f2dece7039ea50a735179046d103cb9846fdd519d068eabff804bf36949917dd", [:mix], [], "hexpm", "e3c2c09d33fbc2392678e5a0fe343fc65309c4747eb753a0c30c13e2e592a90c"}, + "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, + "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"}, + "poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", nil}, + "postgrex": {:hex, :postgrex, "0.15.9", "46f8fe6f25711aeb861c4d0ae09780facfdf3adbd2fb5594ead61504dd489bda", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "610719103e4cb2223d4ab78f9f0f3e720320eeca6011415ab4137ddef730adee"}, + "skogsra": {:hex, :skogsra, "2.3.3", "90ea76d98ad749241b31e724ca17ed8aca0202001972aeca3cb834f44027f3ea", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}, {:yamerl, "~> 0.8", [hex: :yamerl, repo: "hexpm", optional: true]}], "hexpm", "e36880922431d41ac56d6cb4529b0526039a108fb44f8ecc90b517d494b86c28"}, + "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, "uuid": {:hex, :uuid, "1.1.8", "e22fc04499de0de3ed1116b770c7737779f226ceefa0badb3592e64d5cfb4eb9", [:mix], [], "hexpm"}, - "yggdrasil": {:hex, :yggdrasil, "5.0.2", "f76d0e7caa5adbfe769e1f67f2455bc80733d52081d788d38951b94100edb49c", [:mix], [{:exreg, "~> 0.1", [hex: :exreg, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:skogsra, "~> 2.2", [hex: :skogsra, repo: "hexpm", optional: false]}], "hexpm", "cc33a68e9fa56b0bc20b4ad9cd4d280e7ea75f03c3d84acc7463c6adc5da491c"}, + "yggdrasil": {:hex, :yggdrasil, "6.0.0", "6b2cd7290533eaf1f0e8118e2012416b82bb886e13c5efb474152fe6bb903e1c", [:mix], [{:exreg, "~> 1.0", [hex: :exreg, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:skogsra, "~> 2.3", [hex: :skogsra, repo: "hexpm", optional: false]}], "hexpm", "aaa6776010889e8dbda010b19ac1db5c7fbe0d6ef29baa1740fee085131f5d5d"}, } From abe9813b152e0f55a617933d88defdd70baf4a2f Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:30:18 +0200 Subject: [PATCH 2/6] Updated docker-compose --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7f303de..6df37b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,8 @@ services: postgres: image: 'postgres:latest' environment: - POSTGRES_DATABASE: travis_ci_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DATABASE: postgres ports: - '5432:5432' From 2ac2e3e3dcacfaceafc96c7dd43151025145670f Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:31:58 +0200 Subject: [PATCH 3/6] Renamed Settings module to Config to be consistent with Yggdrasil core --- .../{settings => config}/postgres.ex | 19 ++++++++----------- lib/yggdrasil/postgres/connection.ex | 16 ++++++++-------- lib/yggdrasil/postgres/connection/pool.ex | 6 +++--- test/yggdrasil/config/postgres_test.exs | 4 ++++ test/yggdrasil/settings/postgres_test.exs | 4 ---- 5 files changed, 23 insertions(+), 26 deletions(-) rename lib/yggdrasil/{settings => config}/postgres.ex (80%) create mode 100644 test/yggdrasil/config/postgres_test.exs delete mode 100644 test/yggdrasil/settings/postgres_test.exs diff --git a/lib/yggdrasil/settings/postgres.ex b/lib/yggdrasil/config/postgres.ex similarity index 80% rename from lib/yggdrasil/settings/postgres.ex rename to lib/yggdrasil/config/postgres.ex index 83b6eab..243f321 100644 --- a/lib/yggdrasil/settings/postgres.ex +++ b/lib/yggdrasil/config/postgres.ex @@ -1,4 +1,4 @@ -defmodule Yggdrasil.Settings.Postgres do +defmodule Yggdrasil.Config.Postgres do @moduledoc """ This module defines the available settings for PostgreSQL in Yggdrasil. """ @@ -14,16 +14,13 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ Postgres port. Defaults to `5432`. - - iex> Yggdrasil.Settings.Postgres.port() - {:ok, 5432} """ app_env :port, :yggdrasil, [:postgres, :port], default: 5432 @envdoc """ Postgres username. Defaults to `"postgres"`. - iex> Yggdrasil.Settings.Postgres.username() + iex> Yggdrasil.Config.Postgres.username() {:ok, "postgres"} """ app_env :username, :yggdrasil, [:postgres, :username], default: "postgres" @@ -31,7 +28,7 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ Postgres password. Defaults to `"postgres"`. - iex> Yggdrasil.Settings.Postgres.password() + iex> Yggdrasil.Config.Postgres.password() {:ok, "postgres"} """ app_env :password, :yggdrasil, [:postgres, :password], default: "postgres" @@ -39,7 +36,7 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ Postgres database. Defaults to `"postgres"`. - iex> Yggdrasil.Settings.Postgres.database() + iex> Yggdrasil.Config.Postgres.database() {:ok, "postgres"} """ app_env :database, :yggdrasil, [:postgres, :database], default: "postgres" @@ -54,7 +51,7 @@ defmodule Yggdrasil.Settings.Postgres do when `retries <= MAX_RETRIES` and `slot` is given by the configuration variable `#{__MODULE__}.slot_size/0` (defaults to `10` secs). - iex> Yggdrasil.Settings.Postgres.max_retries() + iex> Yggdrasil.Config.Postgres.max_retries() {:ok, 3} """ app_env :max_retries, :yggdrasil, [:postgres, :max_retries], default: 3 @@ -62,7 +59,7 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ Postgres slot size for the backoff algorithm. Defaults to `100`. - iex> Yggdrasil.Settings.Postgres.slot_size() + iex> Yggdrasil.Config.Postgres.slot_size() {:ok, 10} """ app_env :slot_size, :yggdrasil, [:postgres, :slot_size], default: 10 @@ -70,7 +67,7 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ PostgreSQL amount of publisher connections. - iex> Yggdrasil.Settings.Postgres.publisher_connections() + iex> Yggdrasil.Config.Postgres.publisher_connections() {:ok, 1} """ app_env :publisher_connections, @@ -81,7 +78,7 @@ defmodule Yggdrasil.Settings.Postgres do @envdoc """ PostgreSQL amount of subscriber connections. - iex> Yggdrasil.Settings.Postgres.subscriber_connections() + iex> Yggdrasil.Config.Postgres.subscriber_connections() {:ok, 1} """ app_env :subscriber_connections, diff --git a/lib/yggdrasil/postgres/connection.ex b/lib/yggdrasil/postgres/connection.ex index f1b8c51..3a341d1 100644 --- a/lib/yggdrasil/postgres/connection.ex +++ b/lib/yggdrasil/postgres/connection.ex @@ -7,7 +7,7 @@ defmodule Yggdrasil.Postgres.Connection do require Logger - alias Yggdrasil.Settings.Postgres, as: Settings + alias Yggdrasil.Config.Postgres, as: Config @typedoc """ Connection types. @@ -192,11 +192,11 @@ defmodule Yggdrasil.Postgres.Connection do @spec postgres_options(t()) :: Keyword.t() def postgres_options(%State{namespace: namespace}) do [ - hostname: Settings.hostname!(namespace), - port: Settings.port!(namespace), - username: Settings.username!(namespace), - password: Settings.password!(namespace), - database: Settings.database!(namespace) + hostname: Config.hostname!(namespace), + port: Config.port!(namespace), + username: Config.username!(namespace), + password: Config.password!(namespace), + database: Config.database!(namespace) ] end @@ -205,8 +205,8 @@ defmodule Yggdrasil.Postgres.Connection do def backoff(error, state) def backoff(error, %State{namespace: namespace, retries: retries} = state) do - max_retries = Settings.max_retries!(namespace) - slot_size = Settings.slot_size!(namespace) + max_retries = Config.max_retries!(namespace) + slot_size = Config.slot_size!(namespace) new_backoff = (2 <<< retries) * Enum.random(1..slot_size) * 1000 Process.send_after(self(), {:timeout, {:continue, :connect}}, new_backoff) diff --git a/lib/yggdrasil/postgres/connection/pool.ex b/lib/yggdrasil/postgres/connection/pool.ex index a1fc199..0955897 100644 --- a/lib/yggdrasil/postgres/connection/pool.ex +++ b/lib/yggdrasil/postgres/connection/pool.ex @@ -4,8 +4,8 @@ defmodule Yggdrasil.Postgres.Connection.Pool do """ use Supervisor + alias Yggdrasil.Config.Postgres, as: Config alias Yggdrasil.Postgres.Connection - alias Yggdrasil.Settings.Postgres, as: Settings ############ # Public API @@ -88,12 +88,12 @@ defmodule Yggdrasil.Postgres.Connection.Pool do defp get_pool_size(tag, namespace) defp get_pool_size(:subscriber, namespace) do - {:ok, size} = Settings.subscriber_connections(namespace) + {:ok, size} = Config.subscriber_connections(namespace) size end defp get_pool_size(:publisher, namespace) do - {:ok, size} = Settings.publisher_connections(namespace) + {:ok, size} = Config.publisher_connections(namespace) size end end diff --git a/test/yggdrasil/config/postgres_test.exs b/test/yggdrasil/config/postgres_test.exs new file mode 100644 index 0000000..b4a079d --- /dev/null +++ b/test/yggdrasil/config/postgres_test.exs @@ -0,0 +1,4 @@ +defmodule Yggdrasil.Config.PostgresTest do + use ExUnit.Case + doctest Yggdrasil.Config.Postgres +end diff --git a/test/yggdrasil/settings/postgres_test.exs b/test/yggdrasil/settings/postgres_test.exs deleted file mode 100644 index 27a03b6..0000000 --- a/test/yggdrasil/settings/postgres_test.exs +++ /dev/null @@ -1,4 +0,0 @@ -defmodule Yggdrasil.Settings.PostgresTest do - use ExUnit.Case - doctest Yggdrasil.Settings.Postgres -end From 802bf3b526b959f91fe28c96c6c3e0765220b6de Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:32:14 +0200 Subject: [PATCH 4/6] Reformatted project --- lib/yggdrasil/postgres/connection/generator.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/yggdrasil/postgres/connection/generator.ex b/lib/yggdrasil/postgres/connection/generator.ex index 0d95f53..eab75f7 100644 --- a/lib/yggdrasil/postgres/connection/generator.ex +++ b/lib/yggdrasil/postgres/connection/generator.ex @@ -11,7 +11,9 @@ defmodule Yggdrasil.Postgres.Connection.Generator do Starts a connection pool generator. """ @spec start_link() :: Supervisor.on_start() - @spec start_link([DynamicSupervisor.option() | DynamicSupervisor.init_option()]) :: + @spec start_link([ + DynamicSupervisor.option() | DynamicSupervisor.init_option() + ]) :: Supervisor.on_start() def start_link(options \\ []) do DynamicSupervisor.start_link(__MODULE__, nil, options) From 476f6b63c2ac787456f3199aa6775e9410ab725f Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:40:07 +0200 Subject: [PATCH 5/6] Updated docs and changelog --- .gitignore | 4 ++-- CHANGELOG.md | 6 ++++++ README.md | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3ee2583..8d38a99 100644 --- a/.gitignore +++ b/.gitignore @@ -23,8 +23,8 @@ erl_crash.dump .tool-versions # PLTs -priv/plts/skogsra.plt -priv/plts/skogsra.plt.hash +priv/plts/yggdrasil_postgres.plt +priv/plts/yggdrasil_postgres.plt.hash # Language server .elixir_ls diff --git a/CHANGELOG.md b/CHANGELOG.md index daba4d6..55389de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v6.0.0 + + * Updated dependencies. + * Updated docker-compose. + * Moved CI to Github. + ## v5.0.2 ### Enhancements diff --git a/README.md b/README.md index 448fb7c..554fecf 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ available hex package to your `mix.exs` file e.g: ```elixir def deps do - [{:yggdrasil_postgres, "~> 5.0"}] + [{:yggdrasil_postgres, "~> 6.0"}] end ``` From 755b404e365b5fedff2d0181a69807d5f1ddefdc Mon Sep 17 00:00:00 2001 From: Alexander de Sousa Date: Mon, 19 Jul 2021 19:40:53 +0200 Subject: [PATCH 6/6] Updated CI --- .github/workflows/checks.yml | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..5d7e995 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,60 @@ +name: Yggdrasil for PostgreSQL Checks + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + MIX_ENV: test + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DATABASE: postgres + ports: + - 5432/tcp + + strategy: + matrix: + elixir: [1.12.2] + otp: [24.0.3] + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-elixir@v1 + name: "Setup Elixir" + with: + experimental-otp: true + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + - uses: actions/cache@v1 + name: "Retrieves cached PLT" + id: plt-cache + with: + path: priv/plts + key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} + - name: "Get dependencies" + run: mix do local.rebar --force, local.hex --force, deps.get + - name: "Compile dependencies" + run: mix deps.compile + - name: "Compile Yggdrasil for PostgreSQL" + run: mix compile --warnings-as-errors + - name: "Check formatting" + run: mix format --dry-run --check-formatted + - name: "Run Credo" + run: mix credo --strict + - name: "Run tests" + run: mix test + env: + YGGDRASIL_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }} + - name: "Run Dialyzer" + run: mix dialyzer