forked from pachyderm/pachyderm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obj.go
35 lines (30 loc) · 1.19 KB
/
obj.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package obj
import (
"io"
"golang.org/x/net/context"
)
// Client is an interface to object storage.
type Client interface {
// Writer returns a writer which writes to an object.
// It should error if the object already exists or we don't have sufficient
// permissions to write it.
Writer(name string) (io.WriteCloser, error)
// Reader returns a reader which reads from an object.
// If `size == 0` it the reader should read the entire object.
// It should error if the object doesn't exist or we don't have sufficient
// permission to read it.
Reader(name string, offset uint64, size uint64) (io.ReadCloser, error)
// Delete deletes an object.
// It should error if the object doesn't exist or we don't have sufficient
// permission to delete it.
Delete(name string) error
// Walk calls `fn` with the names of objects which can be found under `prefix`.
Walk(prefix string, fn func(name string) error) error
}
func NewGoogleClient(ctx context.Context, bucket string) (Client, error) {
return newGoogleClient(ctx, bucket)
}
func NewAmazonClient(bucket string, id string, secret string, token string,
region string) (Client, error) {
return newAmazonClient(bucket, id, secret, token, region)
}