-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2018 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package storage | ||
|
||
import ( | ||
"storj.io/storj/pkg/paths" | ||
) | ||
|
||
// ListItem is a single item in a listing | ||
type ListItem struct { | ||
path paths.Path | ||
meta Meta | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2018 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package storage | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Meta info | ||
type Meta struct { | ||
Size int64 | ||
Modified time.Time | ||
Expiration time.Time | ||
ContentType string | ||
Checksum string | ||
// Redundancy eestream.RedundancyStrategy | ||
// EncryptionScheme | ||
Data []byte | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (C) 2018 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package objects | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"time" | ||
|
||
monkit "gopkg.in/spacemonkeygo/monkit.v2" | ||
|
||
"storj.io/storj/pkg/paths" | ||
"storj.io/storj/pkg/ranger" | ||
"storj.io/storj/pkg/storage" | ||
"storj.io/storj/pkg/storage/streams" | ||
) | ||
|
||
var mon = monkit.Package() | ||
|
||
// Store for objects | ||
type Store interface { | ||
Meta(ctx context.Context, path paths.Path) (meta storage.Meta, err error) | ||
Get(ctx context.Context, path paths.Path) (rr ranger.RangeCloser, | ||
meta storage.Meta, err error) | ||
Put(ctx context.Context, path paths.Path, data io.Reader, metadata []byte, | ||
expiration time.Time) (meta storage.Meta, err error) | ||
Delete(ctx context.Context, path paths.Path) (err error) | ||
List(ctx context.Context, root, startAfter, endBefore paths.Path, | ||
recursive bool, limit int, metaFlags uint64) (items []paths.Path, | ||
more bool, err error) | ||
} | ||
|
||
type objStore struct { | ||
s streams.Store | ||
} | ||
|
||
// NewStore for objects | ||
func NewStore(store streams.Store) Store { | ||
return &objStore{s: store} | ||
} | ||
|
||
func (o *objStore) Meta(ctx context.Context, path paths.Path) ( | ||
meta storage.Meta, err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
objPath := getDefautStreamPath(path) | ||
return o.s.Meta(ctx, objPath) | ||
} | ||
|
||
func (o *objStore) Get(ctx context.Context, path paths.Path) ( | ||
rr ranger.RangeCloser, meta storage.Meta, err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
objPath := getDefautStreamPath(path) | ||
return o.s.Get(ctx, objPath) | ||
} | ||
|
||
func (o *objStore) Put(ctx context.Context, path paths.Path, data io.Reader, | ||
metadata []byte, expiration time.Time) (meta storage.Meta, err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
objPath := getDefautStreamPath(path) | ||
return o.s.Put(ctx, objPath, data, metadata, expiration) | ||
} | ||
|
||
func (o *objStore) Delete(ctx context.Context, path paths.Path) (err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
objPath := getDefautStreamPath(path) | ||
return o.s.Delete(ctx, objPath) | ||
} | ||
|
||
func (o *objStore) List(ctx context.Context, root, startAfter, | ||
endBefore paths.Path, recursive bool, limit int, metaFlags uint64) ( | ||
items []paths.Path, more bool, err error) { | ||
defer mon.Task()(&ctx)(&err) | ||
rootObjPath := getDefautStreamPath(root) | ||
return o.s.List(ctx, rootObjPath, startAfter, endBefore, recursive, limit, | ||
metaFlags) | ||
} | ||
|
||
func getDefautStreamPath(path paths.Path) paths.Path { | ||
return path.Prepend("object") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (C) 2018 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
package streams | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"time" | ||
|
||
"storj.io/storj/pkg/paths" | ||
"storj.io/storj/pkg/ranger" | ||
"storj.io/storj/pkg/storage" | ||
) | ||
|
||
// Store for streams | ||
type Store interface { | ||
Meta(ctx context.Context, path paths.Path) (storage.Meta, error) | ||
Get(ctx context.Context, path paths.Path) (ranger.RangeCloser, | ||
storage.Meta, error) | ||
Put(ctx context.Context, path paths.Path, data io.Reader, metadata []byte, | ||
expiration time.Time) (storage.Meta, error) | ||
Delete(ctx context.Context, path paths.Path) error | ||
List(ctx context.Context, root, startAfter, endBefore paths.Path, | ||
recursive bool, limit int, metaFlags uint64) (items []paths.Path, | ||
more bool, err error) | ||
} |