From 935bd8460dd732a70cec4564539a94d1761b31fa Mon Sep 17 00:00:00 2001 From: Ygor Castor Date: Wed, 27 Apr 2022 21:03:30 +0200 Subject: [PATCH] [patch] Releasing version --- README.md | 21 +++------------------ lib/ravix.ex | 16 +++++----------- mix.exs | 2 ++ test/connection/connection_test.exs | 5 +---- test/support/test_application.ex | 1 - 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index e93683c..5811f5c 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ Add Ravix to your mix.exs dependencies ## Setting up your Repository -  - Create a Ravix Store Module for your repository ```elixir @@ -28,8 +26,6 @@ defmodule YourProject.YourStore do end ``` -  - You can configure your Store in your config.exs files ```elixir @@ -51,17 +47,14 @@ config :ravix, Ravix.Test.Store, } ``` -  - Then you can start the processes in your main supervisor ```elixir defmodule Ravix.TestApplication do - use Supervisor + use Application - def init(_opts) do + def start(_opts, _) do children = [ - {Ravix, [%{}]}, {Ravix.Test.Store, [%{}]} # you can create multiple stores ] @@ -70,19 +63,11 @@ defmodule Ravix.TestApplication do strategy: :one_for_one ) end - - def start_link(init_arg) do - Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__) - end end ``` -  - ## Querying the Database -  - All operations supported by the driver should be executed inside a session, to open a session you can just call the `open_session/0` function from the store you defined. All the changes are only persisted when the function `Ravix.Documents.Session.save_changes/1` is called! @@ -233,6 +218,7 @@ config :ravix, Ravix.Test.Store, ``` ## Ecto + What about querying your RavenDB using Ecto? [Ravix-Ecto](https://github.com/YgorCastor/ravix-ecto) @@ -255,4 +241,3 @@ What about querying your RavenDB using Ecto? [Ravix-Ecto](https://github.com/Ygo * Attachments The driver is working for the basic operations, clustering and resiliency are also implemented. - diff --git a/lib/ravix.ex b/lib/ravix.ex index 62bdbbf..bd50348 100644 --- a/lib/ravix.ex +++ b/lib/ravix.ex @@ -2,28 +2,22 @@ defmodule Ravix do @moduledoc """ Ravix is a RavenDB Driver written in Elixir """ - use Supervisor + use Application @doc """ Initializes three processes registers to facilitate grouping sessions, connections and nodes. - - :sessions = Stores sessions by their UUIDs + - :sessions = Stores sessions by their UUIDs - :connections = Stores the connections processes, based on the Repo Name - :request_executors = Stores the node executors data """ - def init(_opts) do + def start(_type, _args) do children = [ {Registry, [keys: :unique, name: :sessions]}, {Registry, [keys: :unique, name: :connections]}, {Registry, [keys: :unique, name: :request_executors]} ] - Supervisor.init( - children, - strategy: :one_for_one - ) - end - - def start_link(init_arg) do - Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__) + opts = [strategy: :one_for_one, name: Ravix.Supervisor] + Supervisor.start_link(children, opts) end end diff --git a/mix.exs b/mix.exs index 9a363da..123a099 100644 --- a/mix.exs +++ b/mix.exs @@ -33,6 +33,8 @@ defmodule Ravix.MixProject do # Run "mix help compile.app" to learn about applications. def application do [ + mod: {Ravix, []}, + env: [], extra_applications: [:logger] ] end diff --git a/test/connection/connection_test.exs b/test/connection/connection_test.exs index 35ddc40..af331b0 100644 --- a/test/connection/connection_test.exs +++ b/test/connection/connection_test.exs @@ -1,5 +1,5 @@ defmodule Ravix.Connection.ConnectionTest do - use ExUnit.Case + use Ravix.Integration.Case alias Ravix.Connection alias Ravix.Test.Store, as: Store @@ -7,8 +7,6 @@ defmodule Ravix.Connection.ConnectionTest do describe "update_topology/1" do test "Should update the topology correctly" do - %{ravix: start_supervised!(Ravix.TestApplication)} - :ok = Connection.update_topology(Store) {:ok, state} = Connection.fetch_state(Store) @@ -17,7 +15,6 @@ defmodule Ravix.Connection.ConnectionTest do end test "If all nodes are unreachable, the connection will fail" do - _ravix = start_supervised(Ravix) {:error, _} = start_supervised(InvalidStore) end end diff --git a/test/support/test_application.ex b/test/support/test_application.ex index 4c11754..a32b6c4 100644 --- a/test/support/test_application.ex +++ b/test/support/test_application.ex @@ -4,7 +4,6 @@ defmodule Ravix.TestApplication do def init(_opts) do children = [ - {Ravix, [%{}]}, {Ravix.Test.Store, [%{}]}, {Ravix.Test.NonRetryableStore, [%{}]}, {Ravix.Test.OptimisticLockStore, [%{}]}