Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MySQL backend implementant and support all methods #180

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: go
go:
- 1.7.1

services:
- mysql

# let us have speedy Docker-based Travis workers
sudo: false

Expand All @@ -18,6 +21,7 @@ before_script:
- script/travis_consul.sh 0.6.3
- script/travis_etcd.sh 3.0.0
- script/travis_zk.sh 3.5.1-alpha
- mysql -u root < script/libkv.sql

script:
- ./consul agent -server -bootstrap -advertise=127.0.0.1 -data-dir /tmp/consul -config-file=./config.json 1>/dev/null &
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For example, you can use it to store your metadata or for service discovery to r

You can also easily implement a generic *Leader Election* on top of it (see the [docker/leadership](https://github.com/docker/leadership) repository).

As of now, `libkv` offers support for `Consul`, `Etcd`, `Zookeeper` (**Distributed** store) and `BoltDB` (**Local** store).
As of now, `libkv` offers support for `Consul`, `Etcd`, `Zookeeper` (**Distributed** store), `MySQL` and `BoltDB` (**Local** store).

## Usage

Expand All @@ -34,6 +34,7 @@ You can find examples of usage for `libkv` under in `docs/examples.go`. Optional
- Etcd versions >= `2.0` because it uses the new `coreos/etcd/client`, this might change in the future as the support for `APIv3` comes along and adds more capabilities.
- Zookeeper versions >= `3.4.5`. Although this might work with previous version but this remains untested as of now.
- Boltdb, which shouldn't be subject to any version dependencies.
- MySQL versions >= `5.1.73`.

## Interface

Expand Down Expand Up @@ -62,19 +63,19 @@ Backend drivers in `libkv` are generally divided between **local drivers** and *

Local drivers are usually used in complement to the distributed drivers to store informations that only needs to be available locally.

| Calls | Consul | Etcd | Zookeeper | BoltDB |
|-----------------------|:----------:|:------:|:-----------:|:--------:|
| Put | X | X | X | X |
| Get | X | X | X | X |
| Delete | X | X | X | X |
| Exists | X | X | X | X |
| Watch | X | X | X | |
| WatchTree | X | X | X | |
| NewLock (Lock/Unlock) | X | X | X | |
| List | X | X | X | X |
| DeleteTree | X | X | X | X |
| AtomicPut | X | X | X | X |
| Close | X | X | X | X |
| Calls | Consul | Etcd | Zookeeper | BoltDB | MySQL |
|-----------------------|:----------:|:------:|:-----------:|:--------:|:-------:|
| Put | X | X | X | X | X |
| Get | X | X | X | X | X |
| Delete | X | X | X | X | X |
| Exists | X | X | X | X | X |
| Watch | X | X | X | | X |
| WatchTree | X | X | X | | X |
| NewLock (Lock/Unlock) | X | X | X | | X |
| List | X | X | X | X | X |
| DeleteTree | X | X | X | X | X |
| AtomicPut | X | X | X | X | X |
| Close | X | X | X | X | X |

## Limitations

Expand Down
21 changes: 21 additions & 0 deletions script/libkv.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE DATABASE IF NOT EXISTS `libkv`;
USE `libkv`;
CREATE TABLE IF NOT EXISTS `libkv` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`field0` VARCHAR(127) NOT NULL,
`field1` VARCHAR(127) NOT NULL,
`field2` VARCHAR(127) NOT NULL,
`field3` VARCHAR(127) NOT NULL,
`field4` VARCHAR(127) NOT NULL,
`field5` VARCHAR(127) NOT NULL,
`field6` VARCHAR(127) NOT NULL,
`field7` VARCHAR(127) NOT NULL,
`lock_session` VARCHAR(64) NOT NULL DEFAULT '',
`last_index` BIGINT UNSIGNED NOT NULL,
`value` LONGTEXT NOT NULL,
`create_at` DATETIME NOT NULL,
`update_at` DATETIME NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `by_field` (`field0`,`field1`,`field2`,
`field3`,`field4`,`field5`,`field6`,`field7`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Loading