Skip to content

Commit

Permalink
[patch] Releasing version
Browse files Browse the repository at this point in the history
  • Loading branch information
Ygor Castor committed Apr 27, 2022
1 parent 25d9f53 commit 935bd84
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 34 deletions.
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Add Ravix to your mix.exs dependencies

## Setting up your Repository

 

Create a Ravix Store Module for your repository

```elixir
Expand All @@ -28,8 +26,6 @@ defmodule YourProject.YourStore do
end
```

 

You can configure your Store in your config.exs files

```elixir
Expand All @@ -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
]

Expand All @@ -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!

Expand Down Expand Up @@ -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)

Expand All @@ -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.

16 changes: 5 additions & 11 deletions lib/ravix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions test/connection/connection_test.exs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
defmodule Ravix.Connection.ConnectionTest do
use ExUnit.Case
use Ravix.Integration.Case

alias Ravix.Connection
alias Ravix.Test.Store, as: Store
alias Ravix.TestStoreInvalid, as: InvalidStore

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)

Expand All @@ -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
1 change: 0 additions & 1 deletion test/support/test_application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ defmodule Ravix.TestApplication do

def init(_opts) do
children = [
{Ravix, [%{}]},
{Ravix.Test.Store, [%{}]},
{Ravix.Test.NonRetryableStore, [%{}]},
{Ravix.Test.OptimisticLockStore, [%{}]}
Expand Down

0 comments on commit 935bd84

Please sign in to comment.