Skip to content

Commit

Permalink
full raft implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
autom8ter committed Dec 18, 2020
1 parent 2d066d8 commit 74e91b7
Show file tree
Hide file tree
Showing 34 changed files with 2,653 additions and 1,267 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.1
current_version = 0.8.0
commit = False
tag = False

Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version := "0.7.1"
version := "0.8.0"

.DEFAULT_GOAL := help

Expand All @@ -12,6 +12,13 @@ help:
run:
@go run main.go --open-id https://accounts.google.com/.well-known/openid-configuration

run-follower:
@go run main.go \
--open-id https://accounts.google.com/.well-known/openid-configuration \
--listen-port 8080 \
--join-raft localhost:7820 \
--storage /tmp/graphik2

gen: proto gql

patch: ## bump sem version by 1 patch
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

git clone git@github.com:graphikDB/graphik.git

` docker pull graphikdb/graphik:v0.7.1`
` docker pull graphikdb/graphik:v0.8.0`

Graphik is a Backend as a Service implemented as an identity-aware, permissioned, persistant document/graph database & pubsub server written in Go.

Expand Down Expand Up @@ -71,6 +71,7 @@ Support: support@graphikdb.io
- [x] [Common Expression Language](https://opensource.google/projects/cel) Request Authorization
- [x] [Common Expression Language](https://opensource.google/projects/cel) Type Validators
- [x] Loosely-Typed(mongo-esque)
- [x] Horizontal Scalability/HA via Raft Consensus Protocol
- [x] [Prometheus Metrics](https://prometheus.io/)
- [x] [Pprof Metrics](https://blog.golang.org/pprof)
- [x] Safe to Deploy Publicly(with authorizers/tls/validators/cors)
Expand All @@ -88,18 +89,22 @@ Support: support@graphikdb.io
- go.uber.org/zap
- golang.org/x/oauth2
- github.com/99designs/gqlgen
- https://github.com/hashicorp/raft

## Flags

```text
--allow-headers strings cors allow headers (env: GRAPHIK_ALLOW_HEADERS) (default [*])
--allow-methods strings cors allow methods (env: GRAPHIK_ALLOW_METHODS) (default [HEAD,GET,POST,PUT,PATCH,DELETE])
--allow-origins strings cors allow origins (env: GRAPHIK_ALLOW_ORIGINS) (default [*])
--join-raft string join raft cluster at target address (env: GRAPHIK_JOIN_RAFT)
--listen-port int serve gRPC & graphQL on this port (env: GRAPHIK_LISTEN_PORT) (default 7820)
--metrics enable prometheus & pprof metrics (emv: GRAPHIK_METRICS = true) (default true)
--open-id string open id connect discovery uri ex: https://accounts.google.com/.well-known/openid-configuration (env: GRAPHIK_OPEN_ID)
--playground-client-id string playground oauth client id (env: GRAPHIK_PLAYGROUND_CLIENT_ID)
--playground-client-secret string playground oauth client secret (env: GRAPHIK_PLAYGROUND_CLIENT_SECRET)
--playground-redirect string playground oauth redirect (env: GRAPHIK_PLAYGROUND_REDIRECT) (default "http://localhost:7820/playground/callback")
--raft-peer-id string raft peer ID - one will be generated if not set (env: GRAPHIK_RAFT_PEER_ID)
--require-request-authorizers require request authorizers for all methods/endpoints (env: GRAPHIK_REQUIRE_REQUEST_AUTHORIZERS)
--require-response-authorizers require request authorizers for all methods/endpoints (env: GRAPHIK_REQUIRE_RESPONSE_AUTHORIZERS)
--root-users strings a list of email addresses that bypass registered authorizers (env: GRAPHIK_ROOT_USERS)
Expand Down Expand Up @@ -550,7 +555,7 @@ add this docker-compose.yml to ${pwd}:
version: '3.7'
services:
graphik:
image: graphikdb/graphik:v0.7.1
image: graphikdb/graphik:v0.8.0
env_file:
- .env
ports:
Expand Down Expand Up @@ -584,13 +589,13 @@ to shutdown:

### Linux

curl -L https://github.com/graphikDB/graphik/releases/download/v0.7.1/graphik_linux_amd64 \
curl -L https://github.com/graphikDB/graphik/releases/download/v0.8.0/graphik_linux_amd64 \
--output /usr/local/bin/graphik && \
chmod +x /usr/local/bin/graphik

### Mac/Darwin

curl -L https://github.com/graphikDB/graphik/releases/download/v0.7.1/graphik_darwin_amd64 \
curl -L https://github.com/graphikDB/graphik/releases/download/v0.8.0/graphik_darwin_amd64 \
--output /usr/local/bin/graphik && \
chmod +x /usr/local/bin/graphik

Expand Down
1 change: 1 addition & 0 deletions database/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const (
userType ctxKey = "user"
methodCtxKey ctxKey = "x-graphik-full-method"
bypassAuthorizersCtxKey ctxKey = "x-graphik-authorzer-override"
tokenCtxKey ctxKey = "x-graphik-token"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions database/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (g *Graph) fsm() *fsm.FSM {
return status.Error(codes.Internal, err.Error())
}
}
if err := g.db.Batch(func(tx *bbolt.Tx) error {
if err := g.db.Update(func(tx *bbolt.Tx) error {
if cmd.GetSetAuthorizers() != nil {
for _, a := range cmd.GetSetAuthorizers().GetAuthorizers() {
_, err := g.setAuthorizer(ctx, tx, a)
Expand Down Expand Up @@ -77,7 +77,7 @@ func (g *Graph) fsm() *fsm.FSM {
return errors.Wrap(err, "raft: cacheIndexes")
}
}
if len(cmd.SetDocs) > 0 {
if len(cmd.GetSetDocs()) > 0 {
docs, err := g.setDocs(ctx, tx, cmd.SetDocs...)
if err != nil {
return errors.Wrap(err, "raft: setDocs")
Expand Down
Loading

0 comments on commit 74e91b7

Please sign in to comment.