Skip to content
This repository has been archived by the owner on Nov 23, 2018. It is now read-only.

Use aws-sdk #23

Open
wants to merge 4 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
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: go
go:
- 1.4
- release
- tip
- "1.9"
- "1.10"

script:
- go get -t ./...
Expand Down
35 changes: 14 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/pressly/chainstore"
"github.com/pressly/chainstore/boltstore"
"github.com/pressly/chainstore/lrumgr"
"github.com/pressly/chainstore/metricsmgr"
"github.com/pressly/chainstore/s3store"
"golang.org/x/net/context"
)
Expand All @@ -47,30 +46,31 @@ func main() {
ctx := context.Background()

diskStore := lrumgr.New(500*1024*1024, // 500MB of working data
metricsmgr.New("chainstore.ex.bolt",
boltstore.New("/tmp/store.db", "myBucket"),
),
boltstore.New("/tmp/store.db", "myBucket"),
)

remoteStore := metricsmgr.New("chainstore.ex.s3",
// NOTE: you'll have to supply your own keys in order for this example to work properly
s3store.New(bucketID, accessKey, secretKey),
)
remoteStore := s3store.New(s3store.Config{
S3Bucket: bucketID,
S3AccessKey: accessKey,
S3SecretKey: secretKey,
S3Region: region,
})

dataStore := chainstore.New(diskStore, remoteStore)

// OR.. define inline. Except, I wanted to show store independence & state.
/*
dataStore := chainstore.New(
lrumgr.New(500*1024*1024, // 500MB of working data
metricsmgr.New("chainstore.ex.bolt",
boltstore.New("/tmp/store.db", "myBucket"),
),
boltstore.New("/tmp/store.db", "myBucket"),
),
metricsmgr.New("chainstore.ex.s3",
s3store.New(s3store.Config{
// NOTE: you'll have to supply your own keys in order for this example to work properly
s3store.New("myBucket", "access-key", "secret-key"),
),
S3Bucket: bucketID,
S3AccessKey: accessKey,
S3SecretKey: secretKey,
S3Region: region,
})
)
*/

Expand All @@ -81,13 +81,6 @@ func main() {
log.Fatalf("Open: %q", err)
}

// Since we've used the metricsManager above (metricsmgr), any calls to the boltstore
// and s3store will be measured. Next is to send metrics to librato, graphite, influxdb,
// whatever.. via github.com/goware/go-metrics
// go librato.Librato(metrics.DefaultRegistry, 10e9, ...)

//--

// Save the object in the chain. It will be Put() synchronously into diskStore,
// the boltdb engine, and then immediately dispatch background Put()'s to the
// other stores down the chain, in this case S3.
Expand Down
2 changes: 1 addition & 1 deletion chainstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var (
keyInvalidator = regexp.MustCompile(`(i?)[^a-z0-9\/_\-:\.]`)
keyInvalidator = regexp.MustCompile(`[^a-zA-Z0-9\/_\-:\.]`)
)

const (
Expand Down
3 changes: 1 addition & 2 deletions chainstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/pressly/chainstore/logmgr"
"github.com/pressly/chainstore/lrumgr"
"github.com/pressly/chainstore/memstore"
"github.com/pressly/chainstore/metricsmgr"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
)
Expand Down Expand Up @@ -100,7 +99,7 @@ func TestAsyncChain(t *testing.T) {
},
logmgr.New(logger, "async"),
&testStore{},
metricsmgr.New("chaintest",
chainstore.New(
fs,
lrumgr.New(100, bs),
),
Expand Down
41 changes: 20 additions & 21 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/pressly/chainstore"
"github.com/pressly/chainstore/boltstore"
"github.com/pressly/chainstore/lrumgr"
"github.com/pressly/chainstore/metricsmgr"
"github.com/pressly/chainstore/s3store"
"golang.org/x/net/context"
)
Expand All @@ -18,42 +17,49 @@ var (
bucketID string
accessKey string
secretKey string
region string
)

func init() {
bucketID = os.Getenv("S3_BUCKET")
accessKey = os.Getenv("S3_ACCESS_KEY")
secretKey = os.Getenv("S3_SECRET_KEY")
region = os.Getenv("S3_REGION")

if region == "" {
region = "us-east-1"
}
}

func main() {
ctx := context.Background()

diskStore := lrumgr.New(500*1024*1024, // 500MB of working data
metricsmgr.New("chainstore.ex.bolt",
boltstore.New("/tmp/store.db", "myBucket"),
),
boltstore.New("/tmp/store.db", "myBucket"),
)

remoteStore := metricsmgr.New("chainstore.ex.s3",
// NOTE: you'll have to supply your own keys in order for this example to work properly
s3store.New(bucketID, accessKey, secretKey),
)
remoteStore := s3store.New(s3store.Config{
S3Bucket: bucketID,
S3AccessKey: accessKey,
S3SecretKey: secretKey,
S3Region: region,
})

dataStore := chainstore.New(diskStore, remoteStore)

// OR.. define inline. Except, I wanted to show store independence & state.
/*
dataStore := chainstore.New(
lrumgr.New(500*1024*1024, // 500MB of working data
metricsmgr.New("chainstore.ex.bolt",
boltstore.New("/tmp/store.db", "myBucket"),
),
boltstore.New("/tmp/store.db", "myBucket"),
),
metricsmgr.New("chainstore.ex.s3",
s3store.New(s3store.Config{
// NOTE: you'll have to supply your own keys in order for this example to work properly
s3store.New("myBucket", "access-key", "secret-key"),
),
S3Bucket: bucketID,
S3AccessKey: accessKey,
S3SecretKey: secretKey,
S3Region: region,
})
)
*/

Expand All @@ -64,13 +70,6 @@ func main() {
log.Fatalf("Open: %q", err)
}

// Since we've used the metricsManager above (metricsmgr), any calls to the boltstore
// and s3store will be measured. Next is to send metrics to librato, graphite, influxdb,
// whatever.. via github.com/goware/go-metrics
// go librato.Librato(metrics.DefaultRegistry, 10e9, ...)

//--

// Save the object in the chain. It will be Put() synchronously into diskStore,
// the boltdb engine, and then immediately dispatch background Put()'s to the
// other stores down the chain, in this case S3.
Expand Down
84 changes: 0 additions & 84 deletions metricsmgr/metrics_manager.go

This file was deleted.

35 changes: 0 additions & 35 deletions metricsmgr/metrics_manager_test.go

This file was deleted.

Loading