Documentation ¶
Overview ¶
Package storage defines the standard interface for file storage.
Index ¶
- type ACL
- type Bucket
- type MockServer
- func (m *MockServer) CreateBucket(ctx context.Context, b *Bucket) error
- func (m *MockServer) DeleteBucket(ctx context.Context, name string) error
- func (m *MockServer) DeleteObject(ctx context.Context, bucket, key string) error
- func (m *MockServer) GetBucket(ctx context.Context, name string) (*Bucket, error)
- func (m *MockServer) GetObject(ctx context.Context, bucket, key string) (*Object, error)
- func (m *MockServer) ListBuckets(ctx context.Context) ([]*Bucket, error)
- func (m *MockServer) ListObjects(ctx context.Context, bucket, prefix, from string, max int) ([]*Object, error)
- func (m *MockServer) ObjectMetadata(ctx context.Context, bucket, key string) (*Object, error)
- func (m *MockServer) StoreObject(ctx context.Context, obj *Object) error
- type Object
- type Region
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACL ¶
type ACL string
ACL represents a "canned" access-control list. The value is implementation-specific.
type Bucket ¶
type Bucket struct { // The name of the bucket. Name string // The region of the bucket. May be left empty on return, or ignored // on creation, if the implementation does not support this field. Region Region // The Access Control List of the bucket. May be left empty on return, or // ignored on creation, if the implementation does not support this field. ACL ACL // Metadata contains additional information about the bucket. This is // implementation-specific. Metadata map[string]interface{} }
Bucket represents a bucket where objects can be stored. Not all implementations may support all fields.
type MockServer ¶
type MockServer struct { CreateBucketFunc func(context.Context, *Bucket) error ListBucketsFunc func(context.Context) ([]*Bucket, error) DeleteBucketFunc func(context.Context, string) error GetBucketFunc func(context.Context, string) (*Bucket, error) ListObjectsFunc func(context.Context, string, string, string, int) ([]*Object, error) GetObjectFunc func(context.Context, string, string) (*Object, error) DeleteObjectFunc func(context.Context, string, string) error StoreObjectFunc func(context.Context, *Object) error ObjectMetadataFunc func(context.Context, string, string) (*Object, error) }
MockServer is a test mock for the Server interface.
func (*MockServer) CreateBucket ¶
func (m *MockServer) CreateBucket(ctx context.Context, b *Bucket) error
func (*MockServer) DeleteBucket ¶
func (m *MockServer) DeleteBucket(ctx context.Context, name string) error
func (*MockServer) DeleteObject ¶
func (m *MockServer) DeleteObject(ctx context.Context, bucket, key string) error
func (*MockServer) ListBuckets ¶
func (m *MockServer) ListBuckets(ctx context.Context) ([]*Bucket, error)
func (*MockServer) ListObjects ¶
func (*MockServer) ObjectMetadata ¶
func (*MockServer) StoreObject ¶
func (m *MockServer) StoreObject(ctx context.Context, obj *Object) error
type Object ¶
type Object struct { // BucketName is the name of the bucket where the object is stored. BucketName string // Key is the path of the object in its parent bucket. Key string // Size is the content length of the object in bytes. Size uint64 // Content is the actual content of the object. Note that it is an // io.ReadCloser, it must be closed after use. It is left nil when only the // object's metadata is requested. Content io.ReadCloser // Metadata contains additional information about the object. This is // implementation-specific. Metadata map[string]interface{} }
Object represents an object stored in a bucket. Not all implementations may support all fields.
type Region ¶
type Region string
Region represents a supported region for the storage. The value is implementation-specific.
type Server ¶
type Server interface { // CreateBucket creates a new bucket configured as specified by b. If the context // is cancelled while executing, the operation stops and an error is returned. CreateBucket(ctx context.Context, b *Bucket) error // ListBuckets returns a list of available buckets. If the context is cancelled // while executing, the operation stops and an error is returned. ListBuckets(ctx context.Context) ([]*Bucket, error) // DeleteBucket deletes the specified bucket. If the context is cancelled // while executing, the operation stops and an error is returned. DeleteBucket(ctx context.Context, name string) error // GetBucket returns information about the specified bucket. The level of // details returned is implementation-dependent, but if the operation // succeeds, the returned bucket has at least its name set and it means the // bucket exists and is available. If the context is cancelled while // executing, the operation stops and an error is returned. GetBucket(ctx context.Context, name string) (*Bucket, error) // ListObjects returns a list of objects in a bucket, filtered by prefix, // starting from the from argument (the exact semantic of that parameter is // implementation-specific), with at most max results. If the context is // cancelled while executing, the operation stops and an error is returned. ListObjects(ctx context.Context, bucket, prefix, from string, max int) ([]*Object, error) // GetObject returns the object identified by key stored in bucket. If the // context is cancelled while executing, the operation stops and an error is // returned. GetObject(ctx context.Context, bucket, key string) (*Object, error) // DeleteObject deletes the object identified by key from bucket. If the // context is cancelled while executing, the operation stops and an error is // returned. DeleteObject(ctx context.Context, bucket, key string) error // StoreObject uploads the content of obj to the bucket and key it specifies. // The behaviour of replacing an existing object is implementation-specific. // If the context is cancelled while executing, the operation stops and an // error is returned. StoreObject(ctx context.Context, obj *Object) error // ObjectMetadata returns the metadata of the object identified by key stored // in bucket.If the context is cancelled while executing, the operation stops // and an error is returned. ObjectMetadata(ctx context.Context, bucket, key string) (*Object, error) }
Server defines the methods for a storage server.
Click to show internal directories.
Click to hide internal directories.