• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    Erlang
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A distributed KV store for Erlang and Elixir.

CI Hex pm

Ram

Ram is a distributed KV store for Erlang and Elixir. It chooses Consistency over Availability by using the Raft Consensus Algorithm, and is based on Rabbit MQ's implementation Ra.

[Documentation]

Installation

For Elixir

Add it to your deps:

defp deps do
  [{:ram, "~> 0.5"}]
end

For Erlang

If you're using rebar3, add ram as a dependency in your project's rebar.config file:

{deps, [
  {ram, {git, "git://github.com/ostinelli/ram.git", {tag, "0.5.0"}}}
]}.

Or, if you're using Hex.pm as package manager (with the rebar3_hex plugin):

{deps, [
  {ram, "0.5.0"}
]}.

Quick start

Note: this example below assumes that you are familiar with Distributed Erlang.

Elixir

Open 3 shells and start three Erlang nodes:

$ iex --name [email protected] -S mix
$ iex --name [email protected] -S mix
$ iex --name [email protected] -S mix

Choose the main node (for instance [email protected]), and on that node run the following.

First, create an Erlang cluster by connecting all nodes:

iex(ram1@127.0.0.1)1> nodes = [:"[email protected]", :"[email protected]", :"[email protected]"]
[:"[email protected]", :"[email protected]", :"[email protected]"]
iex(ram1@127.0.0.1)2> for node <- nodes, do: Node.connect(node)
[true, true, true]

Now we can create a Ram cluster running on these nodes:

iex(ram1@127.0.0.1)3> :ram.start_cluster(nodes)
13:03:12.902 [info]  RAM[ram1@127.0.0.1] Cluster started on [:"[email protected]", :"[email protected]", :"[email protected]"]
:ok

You can now store and retrieve values from all the nodes:

iex(ram1@127.0.0.1)4> :ram.put("key", "value")
:ok
iex(ram1@127.0.0.1)5> :ram.get("key")
"value"
iex(ram2@127.0.0.1)1> :ram.get("key")
"value"
iex(ram3@127.0.0.1)1> :ram.get("key")
"value"

Erlang

Open 3 shells and start three Erlang nodes:

$ rebar3 shell --name [email protected]
$ rebar3 shell --name [email protected]
$ rebar3 shell --name [email protected]

Choose the main node (for instance [email protected]), and on that node run the following.

First, create an Erlang cluster by connecting all nodes:

(ram1@127.0.0.1)1> Nodes = ['[email protected]', '[email protected]', '[email protected]'].
['[email protected]','[email protected]','[email protected]']
(ram1@127.0.0.1)2> [net_kernel:connect_node(Node) || Node <- Nodes].
[true,true,true]

Now we can create a Ram cluster running on these nodes:

(ram1@127.0.0.1)3> ram:start_cluster(Nodes).
=INFO REPORT==== 4-Jan-2022::12:46:34.071524 ===
RAM[ram1@127.0.0.1] Cluster started on ['[email protected]','[email protected]',
'[email protected]']
ok

You can now store and retrieve values from all the nodes:

(ram1@127.0.0.1)4> ram:put("key", "value"). 
ok
(ram1@127.0.0.1)5> ram:get("key").
"value"
(ram2@127.0.0.1)1> ram:get("key").
"value"
(ram3@127.0.0.1)1> ram:get("key").
"value"

Configuration Options

release_cursor_count

Specifies after how many logs ram should create a ra snapshot. Defaults to 1000.

Elixir

config :ram,
  release_cursor_count: 1000

Erlang

{ram, [
  {release_cursor_count, 1000}
]}

Other settings

Since Ram uses Ra, please refer to Ra's documentation on available options.

Contributing

So you want to contribute? That's great! Please follow the guidelines below. It will make it easier to get merged in.

Before implementing a new feature, please submit a ticket to discuss what you intend to do. Your feature might already be in the works, or an alternative implementation might have already been discussed.

Do not commit to master in your fork. Provide a clean branch without merge commits. Every pull request should have its own topic branch. In this way, every additional adjustments to the original pull request might be done easily, and squashed with git rebase -i. The updated branch will be visible in the same pull request, so there will be no need to open new pull requests when there are changes to be applied.

Ensure that proper testing is included. To run Ram tests you simply have to be in the project's root directory and run:

$ make test

License

Copyright (c) 2021-2022 Roberto Ostinelli.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

misultin

Misultin (pronounced mee-sool-tΓ©en) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.
Erlang
649
star
2

syn

A scalable global Process Registry and Process Group manager for Erlang and Elixir.
Erlang
622
star
3

apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
Ruby
477
star
4

gin

A LUA fast, low-latency, low-memory footprint, web JSON-API framework with Test Driven Development helpers and patterns.
Lua
238
star
5

SublimErl

An Erlang Plugin for Sublime Text 2, which enables code completion and allows you to run tests within the editor itself.
Python
190
star
6

net-http2

NetHttp2 is an HTTP/2 client for Ruby.
Ruby
140
star
7

pgpool

A PosgreSQL client that automatically uses connection pools and handles reconnections in case of errors.
Erlang
42
star
8

cowbell

An Erlang node connection manager.
Erlang
26
star
9

erlcassa

A Cassandra CQL client.
Erlang
18
star
10

bisbino

An Erlang HTTP server with FastCGI as backend.
Erlang
18
star
11

rebar3_vendor

Rebar3 Vendor Plugin.
Erlang
14
star
12

SCAR_UCM

Utilities Construction Mod for Arma 3.
SQF
11
star
13

PyAES256

An AES-256 cryptographic module for Python.
C
9
star
14

erlgate

An alternative transport for Erlang messages across nodes.
Erlang
8
star
15

lager_airbrake

An Airbrake lager backend.
Erlang
7
star
16

gin-demo

The working demo code of the Gin tutorial on gin.io.
Lua
4
star
17

origami

My standard bootstrap project for distributed TCP applications.
Erlang
3
star
18

SCAR_E2TB

A mod for Arma 3 that allows you to export data to Terrain Builder, from EDEN and in game.
SQF
3
star
19

phpass

A simple implementation of PHPass’ Portable Hash.
Erlang
3
star
20

mochiweb_reloader

Erlang
2
star
21

contextual-git-prompt

Display git information in OSX terminal's prompt.
Shell
2
star
22

pyopenspime

Automatically exported from code.google.com/p/pyopenspime
Python
2
star