• Stars
    star
    175
  • Rank 211,334 (Top 5 %)
  • Language
    Ruby
  • Created almost 12 years ago
  • Updated almost 4 years ago

Reviews

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

Repository Details

Relaxo is a transactional document database built on top of git.

Relaxo

Relaxo is a transactional database built on top of git. It's aim is to provide a robust interface for document storage and sorted indexes. If you prefer a higher level interface, you can try relaxo-model.

Development Status

Installation

Add this line to your application's Gemfile:

gem 'relaxo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install relaxo

Usage

Connect to a local database and manipulate some documents.

require 'relaxo'
require 'msgpack'

DB = Relaxo.connect("test")

DB.commit(message: "Create test data") do |dataset|
	object = dataset.append(MessagePack.dump({bob: 'dole'}))
	dataset.write("doc1.msgpack", object)
end

DB.commit(message: "Update test data") do |dataset|
	doc = MessagePack.load dataset.read('doc1.msgpack').data
	doc[:foo] = 'bar'

	object = dataset.append(MessagePack.dump(doc))
	dataset.write("doc2.msgpack", object)
end

doc = MessagePack.load DB.current['doc2.msgpack'].data
puts doc
# => {"bob"=>"dole", "foo"=>"bar"}

Document Storage

Relaxo uses the git persistent data structure for storing documents. This data structure exposes a file-system like interface, which stores any kind of data. This means that you are free to use JSON, or BSON, or MessagePack, or JPEG, or XML, or any combination of those.

Relaxo has a transactional model for both reading and writing.

Authors

By default, Relaxo sets up the repository author using the login name and hostname of the current session. You can explicitly change this by modifying database.config. Additionally, you can set this per-commit:

database.commit(message: "Testing Enumeration", author: {user: "Alice", email: "alice@localhost"}) do |dataset|
	object = dataset.append("Hello World!")
	dataset.write("hello.txt", object)
end

Reading Files

path = "path/to/document"

DB.current do |dataset|
	object = dataset.read(path)

	puts "The object id: #{object.oid}"
	puts "The object data size: #{object.size}"
	puts "The object data: #{object.data.inspect}"
end

Writing Files

path = "path/to/document"
data = MessagePack.dump(document)

DB.commit(message: "Adding document") do |changeset|
	object = changeset.append(data)
	changeset.write(path, object)
end

Datasets and Transactions

Datasets and Changesets are important concepts. Relaxo doesn't allow arbitrary access to data, but instead exposes the git persistent model for both reading and writing. The implications of this are that when reading or writing, you always see a consistent snapshot of the data store.

Suitability

Relaxo is designed to scale to the hundreds of thousands of documents. It's designed around the git persistent data store, and therefore has some performance and concurrency limitations due to the underlying implementation.

Because it maintains a full history of all changes, the repository would continue to grow over time by default, but there are mechanisms to deal with that.

Performance

Relaxo can do anywhere from 1000-10,000 inserts per second depending on how you structure the workload.

Relaxo Performance
Warming up --------------------------------------
              single   129.000  i/100ms
Calculating -------------------------------------
              single      6.224k (ยฑ14.7%) i/s -    114.036k in  20.000025s
  single transaction should be fast
Warming up --------------------------------------
            multiple   152.000  i/100ms
Calculating -------------------------------------
            multiple      1.452k (ยฑ15.2%) i/s -     28.120k in  20.101831s
  multiple transactions should be fast

Reading data is lighting fast as it's loaded directly from disk and cached.

Loading Data

As Relaxo is unapologetically based on git, you can use git directly with a non-bare working directory to add any files you like. You can even point Relaxo at an existing git repository.

Durability

Relaxo is based on libgit2 and asserts that it is a transactional database. We base this assertion on:

  • All writes into the object store using libgit2 are atomic and synchronized to disk.
  • All updates to refs are atomic and synchronized to disk.

Provided these two invariants are maintained, the operation of Relaxo will be safe, even if there are unexpected interruptions to the program.

The durability guarantees of Relaxo depend on libgit2 calling fsync, and this being respected by the underlying hardware. Otherwise, durability cannot be guaranteed.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Released under the MIT license.

Copyright, 2015, by Samuel G. D. Williams.

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

covered

Ruby
191
star
2

sus

Ruby
148
star
3

jquery-syntax

jQuery.Syntax is a light-weight client-side syntax highlighter.
JavaScript
129
star
4

rack-freeze

A policy framework for implementing thread-safe rack middleware.
Ruby
118
star
5

latinum

Latinum is a framework for resource and currency calculations.
Ruby
109
star
6

turbo_test

Ruby
102
star
7

bake

An alternative to rake, with all the great stuff and a sprinkling of magic dust.
Ruby
92
star
8

fingerprint

Fingerprint is a simple tool that can be used to verify the contents of a directory.
Ruby
71
star
9

script-runner

This package will run various script files inside of Atom. It currently supports JavaScript, CoffeeScript, Ruby, and Python. You can add more.
JavaScript
61
star
10

trenni

A fast native templating system that compiles directly to Ruby code.
Ruby
50
star
11

ffi-clang

Ruby FFI bindings for libclang 3.4+.
Ruby
43
star
12

samovar

Ruby
31
star
13

markly

Ruby wrapper for libcmark, the CommonMark markdown parser.
C
30
star
14

graphviz

A ruby interface for GraphViz graph visualisation toolkit.
Ruby
29
star
15

process-group

Manages a group of processes which can run concurrently using fibers.
Ruby
24
star
16

github-actions-bin

Arch Linux package for GitHub Actions remote runner.
Shell
20
star
17

relaxo-model

A simple business logic model for Relaxo (git-backed database) written in Ruby.
Ruby
20
star
18

bake-test-external

Ruby
16
star
19

activerecord-migrations

A gem to simplify activerecord migrations in non-rails projects.
Ruby
15
star
20

universal-style-guide

14
star
21

periodical

Periodical is a simple framework for working with durations and periods.
Ruby
14
star
22

rack-test-body

Ruby
13
star
23

activerecord-rack

Ruby
13
star
24

rexec

RExec is a tool for executing ruby processes and code both locally and remotely.
Ruby
13
star
25

process-daemon

Define a daemon using a Ruby class, provides common functionality like start, stop.
Ruby
13
star
26

rubykaigi-2022

Ruby
12
star
27

geospatial

Geospatial provides abstractions for dealing with geographical locations efficiently.
Ruby
12
star
28

plotty

Ruby
12
star
29

decode

Ruby
12
star
30

mapping

Ruby
10
star
31

kai

A simple LISP style interpreter written in C++
C++
10
star
32

vips-thumbnail

Ruby
9
star
33

rubykaigi-2023

Ruby
9
star
34

vips

Ruby extension for the vips image processing library.
Ruby
8
star
35

sus-vscode

TypeScript
8
star
36

boolean

Useful methods for working with Booleans
Ruby
8
star
37

time-zone

Ruby
8
star
38

collada

A Ruby library for loading and manipulating Collada .dae files.
Ruby
7
star
39

dream

Dream is a cross-platform framework for making games with C++.
C++
7
star
40

bake-gem

Ruby
6
star
41

bake-modernize

Ruby
6
star
42

zonestar-p802q-fan-duct

C++
6
star
43

synco

A Ruby DSL for running synchronisation and backup tasks.
Ruby
6
star
44

shell-environment

Provides a hook for accessing the user's login environment, e.g. PATH, etc, even when running from a non-login shell environment.
JavaScript
5
star
45

ffi-native

Ruby
5
star
46

hypercube2

OpenSCAD
5
star
47

parallel-merge-sort

A implementation of a fast lock-free parallel merge sort algorithm.
C++
5
star
48

relaxo-query-server

The Relaxo Query Server provides support for executing CouchDB functions using Ruby.
Ruby
5
star
49

git-heatmap

Ruby
4
star
50

fiber-storage

Ruby
4
star
51

goblin-hacker

Goblin Hacker is a save-game editor for Eschalon.
Objective-C
4
star
52

ioquatix

3
star
53

telescopic-tube-clamp

OpenSCAD
3
star
54

transform-flow-capture-ios

A tool for capturing video stream data sets for iOS devices.
Objective-C
3
star
55

bake-test

Ruby
3
star
56

zork

Python
3
star
57

tileshift

A genetic algorithm based platform game for Ludam Dare 2012.
JavaScript
3
star
58

jquery-xframe

A simple client-side include system using AJAX.
Ruby
3
star
59

transform-flow

Transform Flow is a visualisation tool for mobile outdoor augmented reality data sets.
C++
3
star
60

transform-flow-capture-android

Java
3
star
61

print-agent

PrintAgent is a simple authentication system for CUPS.
Ruby
3
star
62

zonestar-p802q-bracing

OpenSCAD
3
star
63

build-environment

Ruby
3
star
64

jquery-syntax-dokuwiki

jQuery.Syntax DokuWiki Plugin.
PHP
2
star
65

hanging-door-roller

OpenSCAD
2
star
66

trenni-formatters

Formatters for Trenni, to assist with typical views and form based interfaces.
Ruby
2
star
67

xapian-core

The latest Xapian core and Ruby bindings.
Ruby
2
star
68

transform-flow-browser-ios

An augmented reality framework using transform flow motion models for iOS.
Objective-C
2
star
69

activerecord-cursor

Ruby
2
star
70

activerecord-blanks

Ruby
2
star
71

presentations

Ruby
2
star
72

xapian-rack

Easily integrate Xapian with Rack.
Ruby
2
star
73

jquery-syntax-wordpress

jQuery.Syntax WordPress Plugin
PHP
2
star
74

autocoverage

Ruby
2
star
75

fiber-annotation

Ruby
2
star
76

jquery-menu

jQuery.Menu is a simple pop-up menu script.
JavaScript
2
star
77

types

Ruby
2
star
78

vulkan-ruby

Ruby
2
star
79

xapian-indexer

Xapian Indexer is an indexing spider written in Ruby and based on Xapian
Ruby
2
star
80

bake-bundler

Ruby
2
star
81

geospatial-kml

Ruby
2
star
82

utopia-gallery

An extension for utopia for displaying photo galleries.
Ruby
1
star
83

many

Ruby
1
star
84

rack-go-http-client-redirect-bug

Ruby
1
star
85

dispatch-benchmark

Objective-C++
1
star
86

build-files-monitor

Ruby
1
star
87

build-makefile

Ruby
1
star
88

transform-flow-data

Sample data sets for Transform Flow.
1
star
89

ARBrowser-Demo

JavaScript
1
star
90

build-dependency

Ruby
1
star
91

bake-github-pages

Ruby
1
star
92

build-graph

Build::Graph is a framework for build systems, with specific functionality for dealing with file based processes.
Ruby
1
star
93

utopia-analytics

Ruby
1
star
94

activerecord-configurations

Manage multiple databases in Rails 5 and Rails 6 with elegance.
Ruby
1
star
95

eventplayer

EventPlayer is a simple JavaScript class to synchronise external events with <audio> and <video> tags.
JavaScript
1
star
96

matx-case

OpenSCAD
1
star
97

Urban-Navigation

Navigation for urban environments.
Objective-C
1
star
98

www.codeotaku.com

My personal website.
JavaScript
1
star
99

computer-science-posters

1
star
100

post_remote_log

Post Remote Log is a simple multi-destination logging system.
Ruby
1
star