Skip to content

Commit 8afb169

Browse files
author
Justin Fudally
committed
Move patched raft-boltdb to internal
1 parent 239ce24 commit 8afb169

File tree

15 files changed

+608
-128
lines changed

15 files changed

+608
-128
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ go 1.13
44

55
require (
66
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878
7+
github.com/boltdb/bolt v1.3.1
78
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
89
github.com/go-sql-driver/mysql v1.5.0 // indirect
910
github.com/hashicorp/go-msgpack v0.5.5
1011
github.com/hashicorp/raft v1.1.2
11-
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617
1212
github.com/julienschmidt/httprouter v1.3.0
1313
github.com/outbrain/golib v0.0.0-20180830062331-ab954725f502
1414
github.com/patrickmn/go-cache v2.1.0+incompatible
1515
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563
16+
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
1617
)

go.sum

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQ
99
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
1010
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
1111
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1213
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1314
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
1415
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@@ -21,24 +22,24 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh
2122
github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=
2223
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
2324
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
25+
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
2426
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
2527
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
2628
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
27-
github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM=
2829
github.com/hashicorp/raft v1.1.2 h1:oxEL5DDeurYxLd3UbcY/hccgSPhLLpiBZ1YxtWEq59c=
2930
github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
3031
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=
31-
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617 h1:CJDRE/2tBNFOrcoexD2nvTRbQEox3FDxl4NxIezp1b8=
32-
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617/go.mod h1:aUF6HQr8+t3FC/ZHAC+pZreUBhTaxumuu3L+d37uRxk=
3332
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
3433
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
3534
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
3635
github.com/outbrain/golib v0.0.0-20180830062331-ab954725f502 h1:oS2s2j8GP70jE0IDMyA4BO4HgvkNcjHfR40h2fyhc7s=
3736
github.com/outbrain/golib v0.0.0-20180830062331-ab954725f502/go.mod h1:JDhu//MMvcPVPH889Xr7DyamEbTLumgDBALGUyXrz1g=
37+
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
3838
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
3939
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
4040
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
4141
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
42+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4243
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4344
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
4445
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
@@ -48,6 +49,7 @@ github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7
4849
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
4950
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5051
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
52+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
5153
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
5254
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
5355
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
File renamed without changes.

internal/raft-boltdb/bench_test.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package raftboltdb
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/hashicorp/raft/bench"
8+
)
9+
10+
func BenchmarkBoltStore_FirstIndex(b *testing.B) {
11+
store := testBoltStore(b)
12+
defer store.Close()
13+
defer os.Remove(store.path)
14+
15+
raftbench.FirstIndex(b, store)
16+
}
17+
18+
func BenchmarkBoltStore_LastIndex(b *testing.B) {
19+
store := testBoltStore(b)
20+
defer store.Close()
21+
defer os.Remove(store.path)
22+
23+
raftbench.LastIndex(b, store)
24+
}
25+
26+
func BenchmarkBoltStore_GetLog(b *testing.B) {
27+
store := testBoltStore(b)
28+
defer store.Close()
29+
defer os.Remove(store.path)
30+
31+
raftbench.GetLog(b, store)
32+
}
33+
34+
func BenchmarkBoltStore_StoreLog(b *testing.B) {
35+
store := testBoltStore(b)
36+
defer store.Close()
37+
defer os.Remove(store.path)
38+
39+
raftbench.StoreLog(b, store)
40+
}
41+
42+
func BenchmarkBoltStore_StoreLogs(b *testing.B) {
43+
store := testBoltStore(b)
44+
defer store.Close()
45+
defer os.Remove(store.path)
46+
47+
raftbench.StoreLogs(b, store)
48+
}
49+
50+
func BenchmarkBoltStore_DeleteRange(b *testing.B) {
51+
store := testBoltStore(b)
52+
defer store.Close()
53+
defer os.Remove(store.path)
54+
55+
raftbench.DeleteRange(b, store)
56+
}
57+
58+
func BenchmarkBoltStore_Set(b *testing.B) {
59+
store := testBoltStore(b)
60+
defer store.Close()
61+
defer os.Remove(store.path)
62+
63+
raftbench.Set(b, store)
64+
}
65+
66+
func BenchmarkBoltStore_Get(b *testing.B) {
67+
store := testBoltStore(b)
68+
defer store.Close()
69+
defer os.Remove(store.path)
70+
71+
raftbench.Get(b, store)
72+
}
73+
74+
func BenchmarkBoltStore_SetUint64(b *testing.B) {
75+
store := testBoltStore(b)
76+
defer store.Close()
77+
defer os.Remove(store.path)
78+
79+
raftbench.SetUint64(b, store)
80+
}
81+
82+
func BenchmarkBoltStore_GetUint64(b *testing.B) {
83+
store := testBoltStore(b)
84+
defer store.Close()
85+
defer os.Remove(store.path)
86+
87+
raftbench.GetUint64(b, store)
88+
}
Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55

66
"github.com/boltdb/bolt"
7-
"github.com/hashicorp/raft"
7+
"github.com/github/freno/internal/raft"
88
)
99

1010
const (
@@ -33,56 +33,26 @@ type BoltStore struct {
3333
path string
3434
}
3535

36-
// Options contains all the configuration used to open the BoltDB
37-
type Options struct {
38-
// Path is the file path to the BoltDB to use
39-
Path string
40-
41-
// BoltOptions contains any specific BoltDB options you might
42-
// want to specify [e.g. open timeout]
43-
BoltOptions *bolt.Options
44-
45-
// NoSync causes the database to skip fsync calls after each
46-
// write to the log. This is unsafe, so it should be used
47-
// with caution.
48-
NoSync bool
49-
}
50-
51-
// readOnly returns true if the contained bolt options say to open
52-
// the DB in readOnly mode [this can be useful to tools that want
53-
// to examine the log]
54-
func (o *Options) readOnly() bool {
55-
return o != nil && o.BoltOptions != nil && o.BoltOptions.ReadOnly
56-
}
57-
5836
// NewBoltStore takes a file path and returns a connected Raft backend.
5937
func NewBoltStore(path string) (*BoltStore, error) {
60-
return New(Options{Path: path})
61-
}
62-
63-
// New uses the supplied options to open the BoltDB and prepare it for use as a raft backend.
64-
func New(options Options) (*BoltStore, error) {
6538
// Try to connect
66-
handle, err := bolt.Open(options.Path, dbFileMode, options.BoltOptions)
39+
handle, err := bolt.Open(path, dbFileMode, nil)
6740
if err != nil {
6841
return nil, err
6942
}
70-
handle.NoSync = options.NoSync
7143

7244
// Create the new store
7345
store := &BoltStore{
7446
conn: handle,
75-
path: options.Path,
47+
path: path,
7648
}
7749

78-
// If the store was opened read-only, don't try and create buckets
79-
if !options.readOnly() {
80-
// Set up our buckets
81-
if err := store.initialize(); err != nil {
82-
store.Close()
83-
return nil, err
84-
}
50+
// Set up our buckets
51+
if err := store.initialize(); err != nil {
52+
store.Close()
53+
return nil, err
8554
}
55+
8656
return store, nil
8757
}
8858

@@ -259,10 +229,3 @@ func (b *BoltStore) GetUint64(key []byte) (uint64, error) {
259229
}
260230
return bytesToUint64(val), nil
261231
}
262-
263-
// Sync performs an fsync on the database file handle. This is not necessary
264-
// under normal operation unless NoSync is enabled, in which this forces the
265-
// database file to sync against the disk.
266-
func (b *BoltStore) Sync() error {
267-
return b.conn.Sync()
268-
}

0 commit comments

Comments
 (0)