From c7a478015e78a9f2f0c926ba3f73ed23e2b7d794 Mon Sep 17 00:00:00 2001 From: Boris Kuznetsov Date: Sun, 2 Feb 2020 20:59:32 +0300 Subject: [PATCH 1/3] remove poison and update dependencies --- README.md | 11 +++++------ lib/waffle.ex | 11 +++++------ mix.exs | 11 +++++------ mix.lock | 11 +++++------ 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index b79fd4e..1b70365 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,13 @@ Add the latest stable release to your `mix.exs` file, along with the required de ```elixir defp deps do [ - waffle: "~> 0.0.4", + {:waffle, "~> 0.0.4"}, # If using Amazon S3: - ex_aws: "~> 2.0", - ex_aws_s3: "~> 2.0", - hackney: "~> 1.6", - poison: "~> 3.1", - sweet_xml: "~> 0.6" + {:ex_aws, "~> 2.1"}, + {:ex_aws_s3, "~> 2.0"}, + {:hackney, "~> 1.9"}, + {:sweet_xml, "~> 0.6"} ] end ``` diff --git a/lib/waffle.ex b/lib/waffle.ex index 26059f9..130987b 100644 --- a/lib/waffle.ex +++ b/lib/waffle.ex @@ -9,14 +9,13 @@ defmodule Waffle do defp deps do [ - waffle: "~> 0.0.4", + {:waffle, "~> 0.0.4"}, # If using Amazon S3: - ex_aws: "~> 2.0", - ex_aws_s3: "~> 2.0", - hackney: "~> 1.6", - poison: "~> 3.1", - sweet_xml: "~> 0.6" + {:ex_aws, "~> 2.1"}, + {:ex_aws_s3, "~> 2.0"}, + {:hackney, "~> 1.9"}, + {:sweet_xml, "~> 0.6"} ] end diff --git a/mix.exs b/mix.exs index 71141ca..56e42fc 100644 --- a/mix.exs +++ b/mix.exs @@ -44,24 +44,23 @@ defmodule Waffle.Mixfile do ] end - def applications(:test), do: [:ex_aws, :ex_aws_s3, :poison] + def applications(:test), do: [:ex_aws, :ex_aws_s3] def applications(_), do: [] defp deps do [ - {:hackney, "~> 1.0"}, + {:hackney, "~> 1.9"}, # If using Amazon S3 - {:ex_aws, "~> 2.0", optional: true}, + {:ex_aws, "~> 2.1", optional: true}, {:ex_aws_s3, "~> 2.0", optional: true}, - {:poison, "~> 2.2 or ~> 3.1", optional: true}, {:sweet_xml, "~> 0.6", optional: true}, # Test - {:mock, "~> 0.1", only: :test}, + {:mock, "~> 0.3", only: :test}, # Dev - {:ex_doc, "~> 0.14", only: :dev}, + {:ex_doc, "~> 0.21", only: :dev}, # Dev, Test {:credo, "~> 1.1.0", only: [:dev, :test], runtime: false} diff --git a/mix.lock b/mix.lock index a15f5ad..82f0894 100644 --- a/mix.lock +++ b/mix.lock @@ -1,11 +1,11 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, - "credo": {:hex, :credo, "1.1.4", "c2f3b73c895d81d859cec7fcee7ffdb972c595fd8e85ab6f8c2adbf01cf7c29c", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.3.5", "0db71c8290b5bc81cb0101a2a507a76dca659513984d683119ee722828b424f6", [:mix], [], "hexpm"}, + "credo": {:hex, :credo, "1.1.5", "caec7a3cadd2e58609d7ee25b3931b129e739e070539ad1a0cd7efeeb47014f4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm"}, "ex_aws": {:hex, :ex_aws, "2.1.1", "1e4de2106cfbf4e837de41be41cd15813eabc722315e388f0d6bb3732cec47cd", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "1.6.3 or 1.6.5 or 1.7.1 or 1.8.6 or ~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: true]}, {:poison, ">= 1.2.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.6", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"}, "ex_aws_s3": {:hex, :ex_aws_s3, "2.0.2", "c0258bbdfea55de4f98f0b2f0ca61fe402cc696f573815134beb1866e778f47b", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, + "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"}, "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, @@ -14,10 +14,9 @@ "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, - "mock": {:hex, :mock, "0.3.3", "42a433794b1291a9cf1525c6d26b38e039e0d3a360732b5e467bfc77ef26c914", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"}, + "mock": {:hex, :mock, "0.3.4", "c5862eb3b8c64237f45f586cf00c9d892ba07bb48305a43319d428ce3c2897dd", [:mix], [{:meck, "~> 0.8.13", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, - "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"}, "sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, From 0c3d728a03f53541827641e01fd563cacacae05b Mon Sep 17 00:00:00 2001 From: Boris Kuznetsov Date: Sun, 2 Feb 2020 21:07:12 +0300 Subject: [PATCH 2/3] correct typo and remove timeout option --- lib/waffle/file.ex | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/waffle/file.ex b/lib/waffle/file.ex index 34ddeb3..712cfa3 100644 --- a/lib/waffle/file.ex +++ b/lib/waffle/file.ex @@ -107,9 +107,8 @@ defmodule Waffle.File do end end - # hakney :connect_timeout - timeout used when establishing a connection, in milliseconds - # hakney :recv_timeout - timeout used when receiving from a connection, in milliseconds - # poison :timeout - timeout to establish a connection, in milliseconds + # hackney :connect_timeout - timeout used when establishing a connection, in milliseconds + # hackney :recv_timeout - timeout used when receiving from a connection, in milliseconds # :backoff_max - maximum backoff time, in milliseconds # :backoff_factor - a backoff factor to apply between attempts, in milliseconds defp get_remote_path(remote_path) do @@ -117,7 +116,6 @@ defmodule Waffle.File do follow_redirect: true, recv_timeout: Application.get_env(:waffle, :recv_timeout, 5_000), connect_timeout: Application.get_env(:waffle, :connect_timeout, 10_000), - timeout: Application.get_env(:waffle, :timeout, 10_000), max_retries: Application.get_env(:waffle, :max_retries, 3), backoff_factor: Application.get_env(:waffle, :backoff_factor, 1000), backoff_max: Application.get_env(:waffle, :backoff_max, 30_000), @@ -135,7 +133,7 @@ defmodule Waffle.File do {:error, :out_of_tries} -> {:error, :timeout} end - _ -> {:error, :waffle_httpoison_error} + _ -> {:error, :waffle_hackney_error} end end From db3ae672c3063161060179ebf94636546a44f093 Mon Sep 17 00:00:00 2001 From: Boris Kuznetsov Date: Sun, 2 Feb 2020 23:36:34 +0300 Subject: [PATCH 3/3] use Jason as a default json encoder --- README.md | 6 +++++- config/config.exs | 3 +++ lib/waffle/storage/s3.ex | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b70365..101669c 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ defp deps do [ {:waffle, "~> 0.0.4"}, - # If using Amazon S3: + # If using S3: {:ex_aws, "~> 2.1"}, {:ex_aws_s3, "~> 2.0"}, {:hackney, "~> 1.9"}, @@ -47,6 +47,10 @@ config :waffle, storage: Waffle.Storage.S3, # or Waffle.Storage.Local bucket: {:system, "AWS_S3_BUCKET"}, # if using Amazon s3 asset_host: "http://static.example.com" # or {:system, "ASSET_HOST"} + +# If using S3: +config :ex_aws, + json_codec: Jason ``` Along with any configuration necessary for ExAws. diff --git a/config/config.exs b/config/config.exs index 042229d..e54fced 100644 --- a/config/config.exs +++ b/config/config.exs @@ -2,3 +2,6 @@ use Mix.Config config :waffle, storage: Waffle.Storage.S3 + +config :ex_aws, + json_codec: Jason diff --git a/lib/waffle/storage/s3.ex b/lib/waffle/storage/s3.ex index df07eae..b37e94b 100644 --- a/lib/waffle/storage/s3.ex +++ b/lib/waffle/storage/s3.ex @@ -28,6 +28,7 @@ defmodule Waffle.Storage.S3 do override if you wish): config :ex_aws, + json_codec: Jason, access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, :instance_role], secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, :instance_role] @@ -111,6 +112,7 @@ defmodule Waffle.Storage.S3 do bucket: "my-frankfurt-bucket" config :ex_aws, + json_codec: Jason, access_key_id: "my_access_key_id", secret_access_key: "my_secret_access_key", region: "eu-central-1",