Skip to content

Commit

Permalink
Merge pull request #130 from infoforcefeed/feature/go-frontend
Browse files Browse the repository at this point in the history
Go Frontend
  • Loading branch information
qpfiffer committed Nov 26, 2014
2 parents 6bffa2c + a8665df commit 02ea474
Show file tree
Hide file tree
Showing 27 changed files with 985 additions and 1,531 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
olegdb
*.o
*.dump
data
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
language: c
compiler:
- gcc
- clang
script: make liboleg oleg_test && export LD_LIBRARY_PATH=./build/lib:$LD_LIBRARY_PATH && ./build/bin/oleg_test
- gcc
- clang
script:
- make liboleg oleg_test
- sudo make install
- export LD_LIBRARY_PATH=./build/lib:$LD_LIBRARY_PATH
- ./build/bin/oleg_test
- LD_LIBRARY_PATH=./build/lib:/usr/local/lib:/usr/lib:$LD_LIBRARY_PATH go test ./...
before_install:
- sudo apt-get update
- sudo apt-get install golang
notifications:
email:
on_success: never
on_failure: change
recipients:
- "[email protected]"
on_success: never
on_failure: change
recipients:
- "[email protected]"
env:
global:
- secure: "GbSMNCqnGnjiuDqJJ55/EaNifx9L7t6JQVPw6illEnGZXL3T5RiC7alrpOQl2qGJG/gwRudMpFmEyvEqs0Rlpgx3x1DvcLCMlC2Rjd/2YklD0KVW0D91Mrrkk7ERzQTO8MXB2AUTxjSAwsZtewybebQhoqr7frulM4TclDZ/Cq4="
Expand Down
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,23 @@ with this one.
ol_bucket *c, *v, *u, *zx;
````
We're probably not going to accept that pull request.
* No tabs, just spaces
* All the above applies for the C code, for the Go frontend we use `gofmt` rules (default settings)
Architecture Decisions
----------------------
Communication is key. If you're making a rather big architecture decision,
discuss it with others. A second pair of eyes often does wonders to reveal weird
or bad ideas.
or bad ideas.
If you don't feel like making an issue or want quick feedback on it, hit us on [IRC](https://olegdb.org/community.html#irc), we do most of our discussions in there.
Code Review
-----------
All code should be code-reviewed by at least one other person before being
merged into master. Master is considered stable and should always pass tests.
Ping @qpfiffer for quick commentary.
Ping [@qpfiffer](github.com/qpfiffer) for quick commentary.
Documentation
-------------
Expand Down
59 changes: 14 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@ ifndef CC
endif
VERSION=0.1.5
SOVERSION=0
BUILD_DIR=$(shell pwd)/build/
CUR_DIR=$(shell pwd)
BUILD_DIR=$(CUR_DIR)/build/
LIB_DIR=$(BUILD_DIR)lib/
BIN_DIR=$(BUILD_DIR)bin/
PREFIX?=/usr/local
INSTALL_LIB=$(PREFIX)/lib/
INSTALL_BIN=$(PREFIX)/bin/
INSTALL_INCLUDE=$(PREFIX)/include/olegdb/
export CGO_LDFLAGS=-L$(BUILD_DIR)lib

ERL_LIB_LOOKFOR=-DLIBLOCATION=\"./build/lib/\"
ERLFLAGS=-smp -W1 -Werror -b beam -I./include -o $(BIN_DIR) $(ERL_LIB_LOOKFOR)
ERL_DIR=$(shell echo 'io:format("~s~n",[code:root_dir()]),init:stop().' | erl | sed -n '/^1>/s/^1> //p')
ERLI_DIR=$(shell echo 'io:format("~s~n",[code:lib_dir(erl_interface)]),init:stop().' | erl | sed -n '/^1>/s/^1> //p')
ERLINCLUDES=-I$(ERL_DIR)/usr/include/ -I$(ERLI_DIR)/include/
ERLLIBS=-L$(ERL_DIR)/usr/lib/ -L$(ERLI_DIR)/lib/
ERL_ODB_INSTALL_DIR=$(ERL_DIR)/lib/olegdb-$(VERSION)
INCLUDES=-I./include

MATH_LINKER=
Expand All @@ -29,27 +24,17 @@ else
MATH_LINKER=-lm
endif

all: liboleg oleg_test server
all: oleg_test frontend

test.o: ./c_src/test.c
$(CC) $(CFLAGS) $(INCLUDES) -c $<

main.o: ./c_src/main.c
$(CC) $(CFLAGS) $(INCLUDES) -c $<

port_driver.o: ./c_src/port_driver.c
$(CC) $(CFLAGS) $(INCLUDES) $(ERLINCLUDES) -c $< -fpic

%.o: ./c_src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -c -fPIC $<

FORCE:

$(BIN_DIR)ol_database.beam: ./src/ol_database.erl FORCE
erlc $(ERLFLAGS) $<

$(BIN_DIR)%.beam: ./src/%.erl
erlc $(ERLFLAGS) $<

oleg_test: $(BIN_DIR)oleg_test
$(BIN_DIR)oleg_test: liboleg test.o main.o
$(CC) $(CFLAGS) $(INCLUDES) -L$(LIB_DIR) -o $(BIN_DIR)oleg_test test.o main.o $(MATH_LINKER) -loleg
Expand All @@ -58,34 +43,18 @@ liboleg: $(LIB_DIR)liboleg.so
$(LIB_DIR)liboleg.so: murmur3.o oleg.o logging.o aol.o rehash.o file.o utils.o tree.o lz4.o stack.o cursor.o data.o transaction.o
$(CC) $(CFLAGS) $(INCLUDES) -o $(LIB_DIR)liboleg.so $^ -fpic -shared $(MATH_LINKER)

server: $(BIN_DIR)ol_database.beam $(BIN_DIR)ol_http.beam \
$(BIN_DIR)ol_parse.beam $(BIN_DIR)ol_util.beam $(BIN_DIR)olegdb.beam \
$(BIN_DIR)ol_route.beam $(LIB_DIR)liboleg.so port_driver.o
$(CC) $(CFLAGS) $(INCLUDES) $(ERLINCLUDES) $(ERLLIBS) -L$(LIB_DIR) -o $(LIB_DIR)libolegserver.so port_driver.o -fpic -shared $(MATH_LINKER) -loleg -lei

uninstall:
rm -rf $(INSTALL_LIB)/liboleg*
rm -rf $(INSTALL_BIN)/olegdb
rm -rf $(ERL_ODB_INSTALL_DIR)
rm -rf $(INSTALL_LIB)liboleg*
rm -rf $(INSTALL_BIN)olegdb

frontend: $(BIN_DIR)olegdb
$(BIN_DIR)olegdb: liboleg
go build -o $(BIN_DIR)olegdb ./frontend/

install: erlinstall
install: goinstall

# The reason we have install twice here is because the variable needs to be compiled install
# when we are installing. It tells erlang where to look
erlinstall: ERL_LIB_LOOKFOR=-DLIBLOCATION=\"$(INSTALL_LIB)\"
erlinstall: libinstall server
@mkdir -p $(INSTALL_BIN)
install $(LIB_DIR)libolegserver.so $(INSTALL_LIB)libolegserver.so.$(VERSION)
ln -fs $(INSTALL_LIB)libolegserver.so.$(VERSION) $(INSTALL_LIB)libolegserver.so
ln -fs $(INSTALL_LIB)libolegserver.so.$(VERSION) $(INSTALL_LIB)libolegserver.so.$(SOVERSION)
@mkdir -p $(ERL_ODB_INSTALL_DIR)/src
@mkdir -p $(ERL_ODB_INSTALL_DIR)/include
@mkdir -p $(ERL_ODB_INSTALL_DIR)/ebin
install $(BIN_DIR)*.beam $(ERL_ODB_INSTALL_DIR)/ebin
install ./include/*.hrl $(ERL_ODB_INSTALL_DIR)/include
install ./src/*.erl $(ERL_ODB_INSTALL_DIR)/src
install ./src/*.app.src $(ERL_ODB_INSTALL_DIR)/ebin
cp ./run_server.sh $(INSTALL_BIN)olegdb
goinstall: frontend libinstall
cp $(BIN_DIR)olegdb $(INSTALL_BIN)olegdb

libinstall: liboleg
@mkdir -p $(INSTALL_LIB)
Expand Down
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ olegdb: No.
OlegDB is a ~~single-threaded, non-concurrent~~, transactionless NoSQL database
written by bitter SQL-lovers in a futile attempt to hop on the schemaless trend
before everyone realizes it was a bad move. It is primarily a C library with an
Erlang frontend for communication.
Go frontend for communication.

Dependencies
============

* A healthy fear of the end
* Erlang
* Go (>= 1.1)

Installation
============

OlegDB consists of a server written in Erlang and a C library for all of the
OlegDB consists of a server written in Go and a C library for all of the
heavy lifting. Binaries are in `build/bin/` and the library is in `build/lib/`.
Beam files are also thrown in `build/bin/`.

Expand All @@ -35,7 +35,7 @@ Currently builds are tested against gcc and clang.
```bash
# Building everything:
make
# Just the erlang beam files:
# Just the golang frontend:
make server
# Just the C library:
make liboleg
Expand All @@ -49,19 +49,14 @@ To run tests:
./run_tests.sh
```

To run the erlang server:
To run the Go server:

```bash
olegdb <db_location>
olegdb [-conf olegdb.conf] [-bind localhost:8080] [-dir data]
```
For an explaination of the command line parameters, do `olegdb -h`

You can optionally specify a port, host or both. But not just a host.

```bash
olegdb <db_location> [[host] port]
```

curl2sudo® install script coming soon.
curl2sudo&reg; install script coming soon.

Documentation
=============
Expand Down
Loading

0 comments on commit 02ea474

Please sign in to comment.