mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 00:25:55 +00:00
Implement S3 writer
This commit is contained in:
parent
bb1157394d
commit
5b586fefc9
1 changed files with 45 additions and 0 deletions
45
bench/store.go
Normal file
45
bench/store.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package bench
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
)
|
||||
|
||||
type Uploader interface {
|
||||
Write(p []byte) (n int, err error)
|
||||
}
|
||||
|
||||
func NewS3Uploader(key string) *S3Uploader {
|
||||
region := "us-east-1"
|
||||
return &S3Uploader{
|
||||
region,
|
||||
"benchmarks-pilosa",
|
||||
s3.New(session.New(&aws.Config{Region: aws.String(region)})),
|
||||
key,
|
||||
}
|
||||
}
|
||||
|
||||
type S3Uploader struct {
|
||||
region string
|
||||
bucket string
|
||||
service *s3.S3
|
||||
key string
|
||||
}
|
||||
|
||||
// pilosa-sandbox is "us-east-1"
|
||||
// benchmarks go to benchmarks-pilosa/run-uuid/??.txt
|
||||
// first return value of PutObject contains an ETag (hash) of the uploaded object, returned here but not needed
|
||||
func (u *S3Uploader) Write(data []byte) (int, error) {
|
||||
fmt.Println(string(data))
|
||||
_, err := u.service.PutObject(&s3.PutObjectInput{
|
||||
Body: strings.NewReader(string(data)),
|
||||
Bucket: &u.bucket,
|
||||
Key: &u.key,
|
||||
})
|
||||
|
||||
return 0, err
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue