Browse Source

Add pool_size, switch to postgres, fix warnings

* Remove unnecessary middleware
* Bump elixir version
brandon 9 years ago
parent
commit
ee031ee693

+ 1 - 1
frameworks/Elixir/phoenix/config/dev.exs

@@ -23,7 +23,7 @@ config :hello, Hello.Endpoint,
   ]
 
 config :hello, Hello.Repo,
-  adapter: Ecto.Adapters.MySQL,
+  adapter: Ecto.Adapters.Postgres,
   username: "benchmarkdbuser",
   password: "benchmarkdbpass",
   database: "hello_world",

+ 3 - 2
frameworks/Elixir/phoenix/config/prod.exs

@@ -7,11 +7,12 @@ config :hello, Hello.Endpoint,
   server: true
 
 config :hello, Hello.Repo,
-  adapter: Ecto.Adapters.MySQL,
+  adapter: Ecto.Adapters.Postgres,
   username: "benchmarkdbuser",
   password: "benchmarkdbpass",
   database: "hello_world",
-  hostname: "localhost"
+  hostname: "localhost",
+  pool_size: 256
 
 # ## SSL Support
 #

+ 3 - 3
frameworks/Elixir/phoenix/mix.exs

@@ -4,7 +4,7 @@ defmodule Hello.Mixfile do
   def project do
    [app: :hello,
     version: "0.0.1",
-    elixir: "~> 1.0",
+    elixir: "~> 1.1",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
@@ -17,7 +17,7 @@ defmodule Hello.Mixfile do
   # Type `mix help compile.app` for more information
   def application do
     [mod: {Hello, []},
-     applications: [:phoenix, :phoenix_ecto, :mariaex, :cowboy, :logger, :phoenix_html]]
+     applications: [:phoenix, :phoenix_ecto, :postgrex, :cowboy, :logger, :phoenix_html]]
   end
 
   defp elixirc_paths(_), do: ["lib", "web"]
@@ -28,7 +28,7 @@ defmodule Hello.Mixfile do
   defp deps do
     [{:phoenix, "~> 1.0.3"},
      {:phoenix_ecto, "~> 1.1"},
-     {:mariaex, ">= 0.0.0"},
+     {:postgrex, ">= 0.0.0"},
      {:cowboy, "~> 1.0.0"},
      {:phoenix_html, "~> 2.1"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},

+ 2 - 3
frameworks/Elixir/phoenix/setup.sh

@@ -4,10 +4,9 @@ fw_depends elixir
 
 sed -i 's|localhost|'${DBHOST}'|g' config/prod.exs
 
-rm -rf _build deps rel
+rm -rf _build deps
 
-MIX_ENV=prod
-export MIX_ENV
+export MIX_ENV=prod
 mix local.hex --force
 mix deps.get --force
 mix compile --force

+ 16 - 10
frameworks/Elixir/phoenix/web/controllers/page_controller.ex

@@ -3,8 +3,6 @@ defmodule Hello.PageController do
   alias Hello.World
   alias Hello.Fortune
 
-  plug :scrub_params, "world" when action in [:create, :update]
-
   def index(conn, _params) do
     json conn, %{"TE Benchmarks\n" => "Started"}
   end
@@ -19,10 +17,14 @@ defmodule Hello.PageController do
   end
 
   def queries(conn, _params) do
-    q = case String.to_integer(_params["queries"]) do
-      x when x < 1    -> 1
-      x when x > 500  -> 500
-      x               -> x
+    q = try do
+      case String.to_integer(_params["queries"]) do
+        x when x < 1    -> 1
+        x when x > 500  -> 500
+        x               -> x
+      end
+    rescue
+      ArgumentError -> 1
     end
     json conn, Enum.map(1..q, fn _ -> Repo.get(World, :random.uniform(10000)) end)
   end
@@ -33,10 +35,14 @@ defmodule Hello.PageController do
   end
 
   def updates(conn, _params) do
-    q = case String.to_integer(_params["queries"]) do
-      x when x < 1    -> 1
-      x when x > 500  -> 500
-      x               -> x
+    q = try do
+      case String.to_integer(_params["queries"]) do
+        x when x < 1    -> 1
+        x when x > 500  -> 500
+        x               -> x
+      end
+    rescue
+      ArgumentError -> 1
     end
     json conn, Enum.map(1..q, fn _ ->
       w = Repo.get(World, :random.uniform(10000))

+ 3 - 3
frameworks/Elixir/phoenix/web/models/world.ex

@@ -1,12 +1,12 @@
 defmodule Hello.World do
   use Hello.Web, :model
 
-  @derive {Poison.Encoder, only: [:id, :randomNumber]}
+  @derive {Poison.Encoder, only: [:id, :randomnumber]}
   schema "world" do
-    field :randomNumber, :integer
+    field :randomnumber, :integer
   end
 
-  @required_fields ~w(randomNumber)
+  @required_fields ~w(randomnumber)
   @optional_fields ~w()
 
   def changeset(model, params \\ nil) do

+ 8 - 8
frameworks/Elixir/phoenix/web/router.ex

@@ -1,20 +1,20 @@
 defmodule Hello.Router do
   use Hello.Web, :router
 
-  pipeline :browser do
-    plug :accepts, ["html"]
-    plug :fetch_session
-    plug :fetch_flash
-    plug :protect_from_forgery
-    plug :put_secure_browser_headers
-  end
+  #pipeline :browser do
+  #  plug :accepts, ["html"]
+  #  plug :fetch_session
+  #  plug :fetch_flash
+  #  plug :protect_from_forgery
+  #  plug :put_secure_browser_headers
+  #end
 
   pipeline :api do
     plug :accepts, ["json"]
   end
 
   scope "/", Hello do
-    pipe_through :browser # Use the default browser stack
+    pipe_through :api # Use the default browser stack
 
     get "/json", PageController, :_json
     get "/db", PageController, :db

+ 1 - 1
toolset/setup/linux/languages/elixir.sh

@@ -8,7 +8,7 @@ RETCODE=$(fw_exists ${IROOT}/elixir.installed)
   return 0; }
 
 ELIXIR_HOME=$IROOT/elixir
-VERSION="1.0.4-1"
+VERSION="1.1.0-1"
 RELEASE="trusty"
 ARCH="amd64"